Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Тестовые примеры / ch4 / ps
.C /* 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;
}
#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