Скачиваний:
16
Добавлен:
01.05.2014
Размер:
466 б
Скачать
/* ps.C */

#include <stdio.h>

int main ()

{

/* execute the command */

FILE * cmdp = popen( "ps -ef | grep root","r" );

if ( !cmdp ) {

perror ( "popen" );

return 1;

}



char result [256] ;

/* now read the "grep" command outputs */

while ( fgets( result, sizeof(result), cmdp ) )

fputs( result, stdout ); // echo each line read



pclose( cmdp ); // close the stream

return 0;

}
Соседние файлы в папке ch4