Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: CGI: Waiting for Output

by benn (Vicar)
on Sep 02, 2003 at 11:08 UTC ( #288290=note: print w/replies, xml ) Need Help??

in reply to CGI: Waiting for Output

Another way may be to use a redirected 'holding pattern' script that checks a semaphore set by your main program. You could even show updates - number of files processed etc.

If your main script creates a temp file that it periodically writes a status to, and deleted when finished, it could pass this filename to "holding.cgi", which can then periodically display the status, then the results when finished - something like this...

#Main File use File::Temp; my ($fh, $filename) = tempfile( DIR => '/tmp'); my ($hfh, $results) = tempfile( DIR => '/html'); print redirect("holding.cgi?file=$filename&html=$results"); do { # process record print $fh $num_records,"\n" unless ($num_processed++ % 1000); } while($records_not_processed); # write results to $hfh # ...or just results.htm... # ...if you haven't got multiple users / datasets etc. unlink $filename; #Holding.cgi my $filename=param('file'); my $html=param('html'); if (-e $filename) { open FILE $filename; # read in last number # print some HTML... # ...that's got a META refresh in... # ...that points back to ourself close FILE; } else {print redirect($html);}
Cheers, Ben.

Replies are listed 'Best First'.
Re: Re: CGI: Waiting for Output
by sutch (Curate) on Sep 02, 2003 at 11:42 UTC
    This works, but is a problem for sites that attempt to provide accessible content. A META refresh may disorient users, since the content may change during mid-viewing without any user interaction. Check out the W3C's Core Techniques for Web Content Accessibility Guidelines for more information.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2021-01-25 15:19 GMT
Find Nodes?
    Voting Booth?