bibliophile has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to have a CGI script ("a.pl") call another CGI script ("b.cgi"), using system(). ("b.cgi" is used elsewhere; I just want to grab its (json) output and do things with it (using Capture::Tiny).
This works fine from the command line, but from the browser, "b.cgi" doesn't get the parameters that "a.pl" sends... or rather, the parms end up in @ARGV rather than $query->param.
Here's a minimal example. In this example, I'm not trying to process b.cgi's output in a.pl... I just want to show that b.cgi is not getting the parameters in $query->param.
a.pl
#!/usr/bin/perl use strict; use warnings; my @args = ("animal=duck", "vegetable=carrot"); system("/usr/bin/perl", "/tmp/b.cgi", @args);
and b.cgi:
#!/usr/bin/perl use warnings; use strict; use CGI; my $query = new CGI; print "Content-type: text/plain\n\n"; print "b.cgi query dump:\n"; print $query->Dump . "\n"; print "b.cgi argv dump:\n"; print join(',', @ARGV); print "\n";
Output when a.pl is invoked from the command line:
Content-type: text/plain b.cgi query dump: <ul> <li><strong>animal</strong></li> <ul> <li>duck</li> </ul> <li><strong>vegetable</strong></li> <ul> <li>carrot</li> </ul> </ul> b.cgi argv dump: animal=duck,vegetable=carrot
Output when a.pl is invoked through the browser:
b.cgi query dump: <ul></ul> b.cgi argv dump: animal=duck,vegetable=carrot
Is there some difference between a command-line invocation and a system() invocation?
I'm clearly misunderstanding something here... Any help you could give would be... well... helpful!
update: spelling
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Invoking a cgi script from another cgi script using system()
by Anonymous Monk on Dec 31, 2014 at 22:50 UTC | |
by bibliophile (Prior) on Jan 01, 2015 at 17:29 UTC | |
by Anonymous Monk on Jan 02, 2015 at 04:31 UTC | |
Re: Invoking a cgi script from another cgi script using system()
by bibliophile (Prior) on Dec 31, 2014 at 21:36 UTC |