SunQuest
           Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Try It Free
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old July 17th, 2000, 07:45 AM
DaveyS DaveyS is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Posts: 2 DaveyS User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old July 17th, 2000, 08:51 AM
freebsd
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
>>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

Reply With Quote
  #3  
Old July 17th, 2000, 09:11 AM
ledjon
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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.

Reply With Quote
  #4  
Old July 17th, 2000, 11:11 AM
ledjon
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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.

Reply With Quote
  #5  
Old July 20th, 2000, 03:25 PM
DaveyS DaveyS is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Posts: 2 DaveyS User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > cgi query


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway