Forgive my naivety here I'm just trying to learn stuff and none of this is going into any production.
I have test.cgi :
use strict;
use warnings;
print "Content-type: text/html\n\n";
print "Test";
my @ret = `./runthis.pl`;
print length(@ret);
print $ret[0];
In runthis.pl I have:
use strict;
use warnings;
print "Hellow World";
Now, locally on my machine, if I run test.cgi as test.pl from the command line this gives @ret length as 1 and shows $ret[0] as hellow world. BUT on my apache server the array shows with a length of 1 but the output hello world doesn't show.
- Do I need to change the STDOUT on runthis.pl? If so how?
- Are there better ways to run a SAFE script as a cgi on apache and get its output into a variable? (The script is just going to output string/text)
Update:
In the end this is what worked with some trial/error suggestions from the good folk here
my @ret = qx(/usr/bin/perl ./runthis.pl`);
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.