Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to execute a 2nd CGI script from my perl script

Status
Not open for further replies.

PerlTrumpsPhp

Programmer
May 21, 2007
8
US
That's the easy question- how can I get my CGI script to launch another CGI script?

The tough part is- it CANNOT wait until the 2nd script gets done loading. I need a way to execute my long-loading-often-browser-time-outting script on the serverside without the user having to wait for their browser to finish.

If you are familiar with CPANEL backups, that's EXACTLY what I want to do. Set the script up, let them know they'll get an email when it's done, and kindly exit the script while launching the other one. Then an hour or so later email them when the script is done.

I tried exec, eval and do. All of which WAIT until the 2nd script finishes.
 
a couple of options..

If your on unix just end your command with a & `/path/to/some/script/test.pl &`;



Fork out a seperate process


Write out some kind of start statement into a file and have a seperate script that is cronned to look at the file and do something when it see's entries


Off the top of my head anyway..
 
Code:
your existing CGI sript here
print "You will get an email when it's done";
exec("otherscript");
#nothing below here


otherscript:

Code:
do whatever
send the email






------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Kevin,

This is what my current script is. It is not ending after I execute the script, it waits and makes the browser load indefinitely until the 2nd script is done.

Code:
#!/usr/bin/perl

use warnings;
use strict;
use CGI qw/:standard/;
use CGI::Carp qw(fatalsToBrowser);


###################
# end configurations
###################
print header, start_html();

print "Please wait until you get an email";

exec("/home/spyders/public_html/cgi-bin/test/spyderlink/test.pl") or die "Error: $!";
 
Travs, I tried adding the & to the end of my exec() but it has the same results.

Thanks.
 
try

Code:
system ("/home/spyders/public_html/cgi-bin/test/spyderlink/test.pl &");

-------------
Cuvou.com | The NEW Kirsle.net
 
try getting rid of the "or die" part:

exec("/home/spyders/public_html/cgi-bin/test/spyderlink/test.pl")

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top