I need to write a CGI program and it will display the output of a system command:
script.sh
echo "++++++"
VAR=$(expect -c " spawn ssh -o StrictHostKeyChecking=no $USER@$HOST $CMD match_max
100000 expect \"*?assword:*\" send -- \"$PASS\r\" send -- \"\r\" expect eof ")
echo $VAR
echo "++++++"
In CGI file:
my $command= "ksh ../cgi-bin/script.sh";
my @output= `$command`;
print @output;
Finally, when I run the CGI file in unix, the $VAR
is a very long string including \n and some delimiters. However, when I run on web server, the output is
++++++ ++++++
So $VAR
is missing when passing in the web interface/browser.
I know maybe the problem is $VAR
is very long string.
But anyway, is there anyway to solve this problem except writing the output to a file then retrieve it from browser?
Thanks if you are interested in my question.