calling linux commands within the cpp program..

Edward Duffy eduffy3@bellsouth.net
Mon Jul 16 18:53:00 GMT 2001


>Dear all,
>It is a big help if anyone give me a clue to call linux commands and their
>results within the cpp program..
>
>Thanks in advance..
>
>Koliya

Do you mean the system() function?

>From the man page...

NAME
       system - execute a shell command

SYNOPSIS
       #include <stdlib.h>

       int system (const char * string);

DESCRIPTION
       system()  executes a command specified in string by calling
/bin/sh -c string, and returns after the
       command has been completed.  During execution of the command, SIGCHLD
will be  blocked,  and  SIGINT
       and SIGQUIT will be ignored.

RETURN VALUE
       The  value returned is 127 if the execve() call for /bin/sh fails, -1
if there was another error and
       the return code of the command otherwise.

       If the value of string is NULL, system() returns nonzero if the shell
is available, and zero if not.

       system() does not affect the wait status of any other children.








More information about the Gcc-help mailing list