Re: [Fwd: Making system Calls ??]

Steve Lamont (spl@szechuan.ucsd.edu)
Fri, 10 Jan 97 10:59:23 PST

To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :

> I can not seem to find the secret for making system calls.
>
> If I use a callback functions for a button
> and do system("who");
> the output goes to stdio. ( the active win )

Do a popen() instead of calling system():

FILE *f;
char buffer[80];

[...]

f = popen( "who", "r" );

while ( fgets( buffer, 80, f ) )
do_your_thing( buffer );

pclose( f ); /* fclose() also works but isn't as kosher */

spl