|
Posted by Bill H on June 6, 2008, 9:00 pm
Please log in for more thread options > Hello,
>
> I'm having an issue with a perl CGI script. =A0The code looks like this:
>
> #!/usr/bin/perl
> use CGI;
> use IO::Handle;
>
> $|=3D1;
>
> [... snip ...]
>
> # Redirect the user to the appropriate output page.
> $io =3D new IO::Handle;
> if ($io->fdopen(fileno(STDOUT),"w")) {
> =A0 =A0 $io->print("Output:output.php?load=3D$sum/$pdbid.html\n");
> =A0 =A0 $io->flush() || die $!;
>
> }
>
> system("cmd & perl backend.pl $pdbid $sum"); =A0 =A0# takes about 4
> minutes to run
>
> My web page makes an AJAX post to this cgi script to start the
> "backend" process. =A0Since that process takes a few minutes, I would
> like the user to be taken to a waiting page. =A0However, I need to pass
> that $sum variable back to the page.
>
> In my head, this code should print the output message to stdout, start
> the backend.pl script in the background, exit and then send the
> contents of stdout down to the web page.
>
> In actuality what happens is there is a delay of several minutes
> before the output message is sent to the page. =A0However, it is not the
> full amount of time required to run backend.pl. =A0It seems to be pretty
> consistently about half of the required time. =A0The page then gets the
> output message, and redirects to the waiting page and works fine from
> thereon out.
>
> Does anyone know how I can get that output message to my webpage
> immediately? =A0As you can see I've tried flushing stdout several
> different ways with no luck.
>
> Also, if there is a better group for me to post to, that would be
> appreciated too.
>
> Thanks,
> Eric
It's been a long day but I think I get the flow of this
Client - > perl - > php - > perl - > client
If this is the case and the 2 perl's in the above are the same program
either 1)eliminate the php and do what it does in perl so you can send
the status back to the client as it is being performed or 2) do it all
in php (same as #1) or 3)have your php call the perl when it is done
so perl isn't waiting and the client isn't waiting.
I think Sinan was close on the suggested link in his first response.
Bill H
|