To execute another CGI (#2) from within your CGI (#1) you have two basic options
Option 1
Execute as if from the command line. There are a couple of variations on this, as discussed by
shemp in his reply. In this case the web server is completely bypassed, and you'll need to simulate any environment vars that your script is expecting to be populated by the web server (browser version for example) and simulate any expected parameters coming into the CGI as well. You may want to do this if, for example, you wish to bypass the .htpasswd access controls.
This can be as simple as this code snippet of mine from one of my tests (using backticks):
$err = `./makeCounter-report.cgi foo=bar`;
ok( $err , '*** makeCounter-report : compile/run ');
Note that this particular CGI uses the debug option allowing command line args to be tranmogrified into params:
use CGI qw/:standard -debug/;
Option 2
Access the CGI #2 as if you were a browser. This can be accomplished using the LWP or CGI module for example as discussed by
LameNerd or
sauoq . In this case since you have gone through the web server, you'll be forced to abide by all the .htaccess permissions.
-------------------------------------
Nothing is too wonderful to be true
-- Michael Faraday
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.