CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
spawning processes in cgi-bin

 



kerki
Deleted

Apr 23, 2000, 10:15 AM

Post #1 of 1 (800 views)
spawning processes in cgi-bin Can't Post

I'm having trouble getting my script to spawn a process (this process needs to output to a file). I would like my forknew.pl script to call profile.pl (which might take a long time to run) and return with a message saying the process has started. The following script runs perfect on the server (i.e. when I type in forknew.pl, it spawns profile.pl and is able to create the output file), but when I use my browser to run it, the output file isn't generated. I've changed all the permissions to 777 for both my cgi-bin and the .pl files.

Here's the listing to forknew.pl:

#!/usr/local/bin/perl5

$time = time().".rpt";
$http = "http://www.somewebsite.com/";

$child_id = fork();
die "fork failed: $!" unless defined $child_id;

if ($child_id)
{
print "Content-type: text/html\n\n";
waitpid($child_id,0);
print "<html>\n<head><title>Forking new process</title></head>\n<body>\n<h1>The parent reaped child $child_id, with status $?</h1>\n</body>\n</html>\n";
} else
{
exec "profile.pl -b -l 2 -o $time $http" &#0124; &#0124; die "Exec $!";
exit 0;
}

Help!

Thanks.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives