Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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


In reply to Invoking a cgi script from another cgi script using system() by bibliophile

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-04-16 23:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found