S
Simon L
hi,
I have a script that calls another module
to exec a script, gets the output back in a array,
and prints out the content of the array using CGI.
If I run the script at the command line, it prints
everything from the array correctly. However, if
I run it on the brower, the program runs but nothing
from the array gets displayed on the page. I have
struggled with it for a while, any insight would be
greatly appreciated.
my $line;
my (@stdout, @stderr);
# $program_name is another Perl script
my $scr = '/user/ice/htdocs/' . $program_name;
# command to be sent to another program to exec
my @cmd = ($scr, '-mode', $Mode, '-U', 'xxx', '-P', 'xxx', '-App', $AppName);
# send for exec and gets its STDOUT and STDERR back using
# @stdout and @stderr
my $rc = ForkAndReadStdoutStderr(\@stdout, \@stderr, @cmd);
if ($rc < 0)
{ print $Cgi->p($ICE::Fork::ERROR) }
if ($rc > 0)
{ print $Cgi->p("@cmd FAILED! stdout=@stdout;stderr=@stderr") }
print header('text/plain');
foreach $line (@stdout)
{
print $line;
}
My temporary solution now is to send the output
of the script that I system() to a file and
use "print redirect()" to display the file.
Thanks,
SL
I have a script that calls another module
to exec a script, gets the output back in a array,
and prints out the content of the array using CGI.
If I run the script at the command line, it prints
everything from the array correctly. However, if
I run it on the brower, the program runs but nothing
from the array gets displayed on the page. I have
struggled with it for a while, any insight would be
greatly appreciated.
my $line;
my (@stdout, @stderr);
# $program_name is another Perl script
my $scr = '/user/ice/htdocs/' . $program_name;
# command to be sent to another program to exec
my @cmd = ($scr, '-mode', $Mode, '-U', 'xxx', '-P', 'xxx', '-App', $AppName);
# send for exec and gets its STDOUT and STDERR back using
# @stdout and @stderr
my $rc = ForkAndReadStdoutStderr(\@stdout, \@stderr, @cmd);
if ($rc < 0)
{ print $Cgi->p($ICE::Fork::ERROR) }
if ($rc > 0)
{ print $Cgi->p("@cmd FAILED! stdout=@stdout;stderr=@stderr") }
print header('text/plain');
foreach $line (@stdout)
{
print $line;
}
My temporary solution now is to send the output
of the script that I system() to a file and
use "print redirect()" to display the file.
Thanks,
SL