Superman has asked for the wisdom of the Perl Monks concerning the following question:

I have a webform which retrieves data and passes it to a CGI script. My script retrieves 3 variables which then have to run 4 different C++ programs to retrieve the information i want

At the moment i have defined my commands as
$command1="/cgi-bin/c++prog1"."|" $command2="/cgi-bin/c++prog2"."|" $command3="/cgi-bin/c++prog3"."|" $command4="/cgi-bin/c++prog4"."|"
and run them using the system command
system("$command1"); system("$command2");...
but the script is not working!

If i want to run a simple script then using a simple filehandle command does the trick but i need to run all 4 programs in the order that they are!

Is there anyone there that can help me?

thanking you in advance

Replies are listed 'Best First'.
Re: Running another program
by chromatic (Archbishop) on Jul 21, 2001 at 05:43 UTC
    "Not working" is fairly ambiguous. Nevertheless, this sounds like Why can't I get the output of a command with system()? found in perlfaq8. (Type 'perldoc perlfaq8' from the command line.)

    If that shot in the dark completely misses the mark, feel free to respond with what the script actually does (including output and error messages) and what you expect it to do.

Re: Running another program
by synapse0 (Pilgrim) on Jul 21, 2001 at 06:28 UTC
    Ok.. i'm confused here.. what is posted now is quite a bit different than what was originally posted. When i first read this post, it sounded like the command being run was more like system("/cgi-bin/c++prog1 | /cgi-bin/c++prog2 | etc.."); which is still slightly visible in the more readable changed version now posted. Now, did the poster change his message or did someone else? if it was the poster, you really should post your *exact* script snippets, because what is showing now is completely flawed (as of this writing). If someone else changed it, it completely changed the original syntax, which was not several system calls but one. My orginal suggestion would have been that several system calls needed to be made, because it looked like the poster didn't fully grasp what the pipe was doing to his system call. Now i'm just confused.
    What's the real story here?
    -Syn0
Re: Running another program
by tadman (Prior) on Jul 21, 2001 at 10:37 UTC
    my @programs = ("/cgi-bin/c++prog1", "/cgi-bin/c++prog2", "/cgi-bin/c++prog3", "/cgi-bin/c++prog4" ); foreach (@programs) { open (F, "$_|"); while (<F>) { print; } close (F); }
Re: Running another program
by bschmer (Friar) on Jul 21, 2001 at 07:06 UTC
    Perhaps what you want is to do open(FH, $cmd);. You can then read the output of the commands from FH.