Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: CGI: Waiting for Output

by benn (Priest)
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.


Comment on Re: CGI: Waiting for Output
Download Code
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2015-07-06 03:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (69 votes), past polls