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
2
  • my $d=qx(perl -cw 1.cgi 2>&1); Commented Jul 18, 2017 at 13:49
  • More about 2>&1 Commented Jul 18, 2017 at 13:51

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.