|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
I have a perl script, blah.cgi in local cgibin directory on a unix box running apache - works fine. I would like it to call another perl script (preferably spawning it off) called child.cgi.
1) can I exec it with $foo="child.fgi" exec ($foo) or die ("Aaargh"); 2) should I system() it instead ? 3) should child.cgi have some kind of path in front (where does apache look?)? many thanks |
|
#2
|
|||
|
|||
|
>>1) can I exec it with $foo="child.fgi"..
it depends >>2) should I system() it instead ? Maybe not. Please specify exactly what blah.cgi and child.cgi do, maybe I can think of another way of doing the exact task >>3) should child.cgi have some kind of path in front You can just treat it as a normal cgi file like having #!/usr/local/bin/perl at the first line |
|
#3
|
|||
|
|||
|
The best thing to do (assuming child.cgi isn't run for anything but this) is to make the stuff in child.cgi, or at least the part you want to called, a sub routine. then you can require 'child.cgi'; and call the sub routine.
|
|
#4
|
|||
|
|||
|
Another thing you can do (if you want this called to a webpage or from a remote server) is to use the libwww-perl library. (You have to have that installed on the server).
Then in the cgi file that calls it use the following: -------------------- #!/usr/bin/perl # #Remote Include #by: Jon Coulter - ledjon@ledjon.com # ####URL of File to be Included - Full URL#### $url = "http://www.yoursite.com"; ####Use libwww-perl#### use LWP::Simple; ####Header#### print "Content-type: text/htmlnn"; ####Do some checking!#### #This check to see if something like "script.pl?http://www.asdf.com/asdf.cgi" has been called. #If there's nothing entered it used the default (defined above). $qstring = $ENV{'QUERY_STRING'}; if ($qstring ne "") {$url = $qstring} ####Get the Info!#### $script_output = getprint("$url"); ####Print it out#### print "$script_output"; ---------------------- Note: That's a completly working script I wrote that called remote (meaning on a different server) files for includes. I use it alot at work. |
|
#5
|
|||
|
|||
|
More to the point, what child.cgi is required to do is to 'clean up' after normal routines - The cgi process creates some workfiles, but I need to cope with the fact that some user will get part way thru the process then wander off elsewhere. So I need a job to wait nn minutes then activate and purge workfiles (naturally created with $$ in name, and $$ passed to child as targets to kill after sleep nn*60.)
So I thought - why not & off a job to shell, let it sleep a bit then asassinate workfiles. Am I approaching this wrong ? D |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > cgi query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|