3

below is the code, please give me any suggestions to display the result of the command output.

#!/usr/bin/perl
use strict; 
use warnings;
print "content-type:text/html\r\n\r\n";
print <<EOF;
<html>
<head><title>command</title></head>
<body>
EOF
my $d=qx(perl -cw 1.cgi);
print <<EOF;
<p>$d</p>
</body>
</html>
EOF

1 Answers1

3

qx will return the STDOUT in variable but you are trying to store the Perl compiling result into your variable, In Linux it is called as STDERR not a STDOUT so we need to do as follow

my $d=qx(perl -cw 1.cgi 2>&1);

More about 2>&1

mkHun
  • 5,891
  • 8
  • 38
  • 85