CGI.pm usually lets me pass parameters to a Perl CGI script, when the script is executed from the command line. However, I can't pass the parameters to a Perl CGI script, when the script is executed within the Perl system function. The following CGI script (called test7.pl) reads the query string and prints it to standard error.
#!/usr/bin/perl -w use strict; use CGI qw/:standard/; my $x = query_string() || 'undefined'; warn("x =$x"); print("Hello\n"); #print param('name')."\n";
The next CGI script (called test8.pl) uses the system function to pass data to test7.pl
#!/usr/bin/perl -w use strict; use CGI qw/:standard/; print header(), start_html('test'); print h1(system("./test7.pl name=5 val=3 x=13 > temp.dat; mv temp.dat +temp1.dat")); print h1(system("./test7.pl name=5 val=4")); print end_html();
If I run test8.pl from the shell, we see the passed parameters.
x =name=5;val=3;x=13 at ./test7.pl line 8. x =name=5;val=4 at ./test7.pl line 8.
If I run test8.pl from the browser, we don't see the parameters.
sh: line 1: temp.dat: Permission denied mv: temp.dat: No such file or directory x =undefined at ./test7.pl line 8.
Why doesn't the system function pass the CGI parameters in? And why does the redirection fail?

In reply to Why doesn't the system function pass the CGI parameters in? by esharris

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.