SPUG: Showing progress in the browser

William Julien moonbeam at catmanor.com
Thu Jan 22 14:39:24 CST 2004

>I have a question I would like to show the progress on the CGI on the browser for example 10%, 20% 40% of complision. or something like that...Any one knows how I can do this??..

You can do this with an "nph" script. Here is a "hello world"


# this is a demonstration of server push

# enable autoflush
$| = 1;   

# send the http header to establish the boundry
print "HTTP/1.0 200\n";
print "Content-type: multipart/x-mixed-replace; boundary=ThisRandomString\n\n"

# start the first boundry
print "--ThisRandomString\n";

# loop 10 times
$i = 0;
while ($i < 10) {
  print "Content-type: text/html\n\n";
  print "<html><body><title>This is run $i</title>\n";
  print "<h1>This is run $i</h1></body></html>\n";
  print "--ThisRandomString\n";
  sleep 2;

# send the last page
print "Content-type: text/html\n\n";
print "<html><body><title>Fin</title>\n";
print "<h1>Fin</h1></body></html>\n";
print "--ThisRandomString--\n";

exit 0;                        


No problem

>Seattle Perl Users Group Mailing List  
>POST TO: spug-list at mail.pm.org  http://spugwiki.perlocity.org
>ACCOUNT CONFIG: http://mail.pm.org/mailman/listinfo/spug-list
>MEETINGS: 3rd Tuesdays, U-District, Seattle WA
>WEB PAGE: http://www.seattleperl.org

More information about the spug-list mailing list