Computing.Net > Forums > Linux > suppress output from a command to STDOUT

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

suppress output from a command to STDOUT

Reply to Message Icon

Name: matt smith
Date: May 15, 2002 at 14:45:55 Pacific
Comment:

I am running a cgi program on apache which
runs an executable and assigns a variable
to the output like this (in perl):

my $results = system "/usr/bin/exe $arg";

my problem is that this executable also
tries to PRINT the results to STDOUT - this
causes me problems because it either messes
up my cgi headers or it messes up my HTML
(depending on whether I print headers
before or after I call the executable)

I have tried redirecting output to a file
and that doesn't work either
ex
$results = system "/usr/local/exe $arg >>
/tmp/file";

help :-)



Sponsored Link
Ads by Google

Response Number 1
Name: junky_toof
Date: May 15, 2002 at 15:01:08 Pacific
Reply:

ordinarily you would just do something like
this:
a = system("ls * 2&1 > /dev/null");
if (a != 0) {
printf "%s", "Bogus run::program failed";
} else {
EXIT_SUCCESS;
}

YMMV, I tried it with awk and in C, and got
different results depending on how I passed
the command to execve. As ARGV[1] in awk it
was almost impossible. In C it was trivial,
so...
BTW, I hate perl it's a write only language.


0

Response Number 2
Name: matt
Date: May 16, 2002 at 19:19:06 Pacific
Reply:

thanks for the help -
i did try redirection to /dev/null and it
still wanted to print -> the kludge i ended
up with was embedding the return garbage in
a META tag - it still prints but now, no
one has to look at it! :-)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: suppress output from a command to STDOUT

Command to find files and update www.computing.net/answers/linux/command-to-find-files-and-update/29768.html

adding a boot from cd option to lilo? www.computing.net/answers/linux/adding-a-boot-from-cd-option-to-lilo/6529.html

Installing from a download www.computing.net/answers/linux/installing-from-a-download/1108.html