[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 01:38:46 -0500 |
Support Request #101494, was updated on 2002-Nov-06 06:36
You can respond by visiting:
http://savannah.gnu.org/support/?func=detailsupport&support_id=101494&group_id=11
Category: Web
Status: Closed
Priority: 5
Summary: problem with using "system()" and "pope"
By: yeupou
Date: 2002-Nov-06 07:38
Logged In: YES
user_id=1896
Browser: Mozilla/5.0 Galeon/1.2.5 (X11; Linux i686; U;) Gecko/20020623
Debian/1.2.5-0.woody.1
This support tracker is only dedicated to matters related to
project hosting on savannah, sorry.
----------------------------------------------------------------------
By: fanhaipeng
Date: 2002-Nov-06 06: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