savannah-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Savannah-hackers] [ 101494 ] problem with using "system()" and "pope"


From: nobody
Subject: [Savannah-hackers] [ 101494 ] problem with using "system()" and "pope"
Date: Wed, 06 Nov 2002 00:36:36 -0500

Support Request #101494, was updated on 2002-Nov-06 05:36
You can respond by visiting: 
http://savannah.gnu.org/support/?func=detailsupport&support_id=101494&group_id=11

Category: Web
Status: Open
Priority: 5
Summary: problem with using "system()" and "pope"

By: fanhaipeng
Date: 2002-Nov-06 05:36
Logged In: YES 
user_id=12332
Browser: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)

I make a program in Red Hat Linux7.2, which was 
designed to control the action of Apache Web Server. I 
call function system() to execute the command which 
control Apache, such as below:

system("/usr/local/apache/bin/apachectl start");

It will start the Apache Web Server. And, I use popen 
create a pipe to communicate with the call of system() 
in order to receive the output of the command,which 
will be saved. The code is like:

input = popen (strcmd, "r");
if (!input){
    fprintf (stderr, "Could not run command.\n");
    return EXIT_FAILURE;
}
i = 0;
while ((c = fgetc (input)) != EOF)
    outbuf[i++] = c;
outbuf[i] = 0;
pclose (input);
printf("outbuf: %s",outbuf);

It does work when I execute the command apachectl with 
some options, but it doesn't work with other 
options,such as "apachectl configtest" and "apachectl 
status", the variable "input" got nothing after the 
command being executed. I think that the output of 
these command may be direct to the stderr so that the 
pipe couldn't get it, for I was told by some gcc 
document that popen create a pipe which can read the 
output of stdout of command executed by system. I 
don't know how to deal with this problem.

Waiting for reply... ...
Please send your advice to my email: 
address@hidden

Thank you!




----------------------------------------------------------------------
You can respond by visiting: 
http://savannah.gnu.org/support/?func=detailsupport&support_id=101494&group_id=11




reply via email to

[Prev in Thread] Current Thread [Next in Thread]