get system() answer ?

Hi ,
how can i get the system reply from a system() command ?
is it possible to evaluate the return of a system command ?

If you want to read the output from the command, you need to use popen rather than system.

The return code from system just tells you whether it could run the command or not.

Perderabo,

Can you please futher elaborate how to use the "popen" ?

There is a man page on popen. But here is a quick example...

FILE *pipe;
char line[MAXLINE];
pipe=popen("/usr/bin/pwd", "r");
fgets(line,MAXLINE,pipe);
pclose(pipe);

Thank you perderabo, I will try on it. By the way, I sent you an email.