homepage Welcome to WebmasterWorld Guest from 54.196.225.45
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
run perl scripts on background
msgsbox




msg:3073924
 7:08 pm on Sep 6, 2006 (gmt 0)

I have a html 'form.html' that will call 'sample.cgi'. After an user submit this form, 'sample.cgi' will be loading. But there is a perl scripts ,'sample.pl', in 'sample.cgi', which takes a while to run, so 'sample.cgi' page will keep on loading until 'sample.pl' stops.

How to let perl scripts, 'sample.pl' run on background? And then that 'sample.cgi' can be loaded quickly.

Thanks!

 

rocknbil




msg:3074443
 5:33 am on Sep 7, 2006 (gmt 0)

Google for fork.

if ($pid = fork) { ...parent process ... }
else { ... child process ... }

msgsbox




msg:3074913
 2:23 pm on Sep 7, 2006 (gmt 0)

Thanks <b>rocknbil</b>!

I found a link about 'fork': [oreilly.com...]

I run that example in Unix, and it works (run child process in background).

But when I run it in Browser, it doesnot work. Browser (firefox) keeps on loading until child process finished, although we can close browser.

perl_diver




msg:3075171
 6:01 pm on Sep 7, 2006 (gmt 0)

yea, I don't think you can do what you are trying to do. Can you run the other script last instead of first?

msgsbox




msg:3075185
 6:12 pm on Sep 7, 2006 (gmt 0)

What did you mean, Perl-driver?

Form.html: where user fills information.
Sample.cgi: get information from Form.html
Job.pl: use infromation to execute some tasks (but it takes some time)

What I wanted is:
load Sample.cgi and tell user, job is running and email will be sent out when done.

Job.pl will be run on background.

Problem: Sample.cgi keeps on loading until Job.pl finished, although you can forcedly close Sample.cgi.

Solution:?

Many thanks!

perl_diver




msg:3075326
 8:04 pm on Sep 7, 2006 (gmt 0)

sample.cgi

sample.cgi does some stuff
print "You will recieve an email shortly";
exec(job.pl);

that should do it. When you run a program from the exec() function the current script is replaced by the new one and the old script is exited. job.pl runs and sends an email when finished.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved