This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: calling linux commands within the cpp program..
- To: <gcc-help at gcc dot gnu dot org>
- Subject: Re: calling linux commands within the cpp program..
- From: "Edward Duffy" <eduffy3 at bellsouth dot net>
- Date: Tue, 17 Jul 2001 09:49:31 -0400
>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.