OK, 5 hours later and I'm stumped...
I need to run a program from a perl CGI script. The invoked program must be completely severed from the original program, thus allowing the output of the original program to go to the client browser while the invoked program does it's ridiculously long task. I've tried lots of stuff, 'fork && exit;', 'use POSIX qw(setsid)', 'system (cmd &)' and even tried experimenting with open and pipes.
Here is the code:
PROGRAM1:
#/usr/bin/perl
# program1.cgi is invoked by a web browser
#
print <<EOF;
Content-type: text/html
<html>
<body>
this output should come up while program2.cgi is still thinking
</body>
</html>
EOF
# at this point, we want to invoke program2.cgi and terminate program1
+.cgi
exit 1;
PROGRAM2:
#/usr/bin/perl
# program2.cgi does something incredibly long but has no output to STD
+OUT, so we would like this sucker to run independently of program1.cg
+i.
sleep 200;
exit 1;
any help will be appreciated most sincerely,
f.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.