Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Re: Re: Re: Executing another script from a CGI

by higle (Chaplain)
on Jul 25, 2002 at 14:06 UTC ( [id://185198]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Executing another script from a CGI
in thread Executing another script from a CGI

Yeah, that was the next problem. At first I was using the backticks, but the problem was that the utility script took 20 or so minutes to run, and the backtick operator only returns after the child process has stopped running, so the operation timed out from the browser. I of course was using a nohup to keep the utility script running on the server, but the end user would see it as an error...

I implemented the open method after that, and it works beautifully :)

Final, working code (minus sensitive info):

...........................
#!/opt/perl5/bin/perl -w use strict; use CGI; # set path, instead of putting it in the open statement $ENV{'PATH'} = "/usr/bin:/opt/perl5/bin/:"; #location of product_gen.pl, plus arguments my $gen_script = "/path/to/server/product_gen.pl -prfv"; # Create a new CGI object my $cgi = new CGI; # Output HTML header to browser print $cgi->header('text/html'); print qq{<h4>script executing</h4>}; open(PRODUCT_GEN, "nohup perl $gen_script |") or die "Error: $!\n"; while (<PRODUCT_GEN>) { print $_, "<br>"; } close(PRODUCT_GEN);
...........................

Thanks again for all the assistance!

  higle

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://185198]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-24 23:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found