Dear monks,

I have a long running process (C program) that is invoked by the perl script and every second sends back statistical data to the perl script. The script than needs to display it on the web page. Since my server push method is timing out intermittently, I have decided to give client pull a try. First, I displayed a dummy page with a "refresh" header of 3 seconds. During this 3 seconds, my perl script would retrieve data from the C program and create an html page on disk named page1.html. After displaying the dummy page for 3 seconds, the "refresh" would take the browser to page1.html and display it for 3 seconds while the perl script creates page2.html with new data. Page1.html then "refresh" and called page2.html to be displayed for 3 seconds. Page2.html then "refresh" and called page1.html and so on until the process is finished. The problem I am encountered is that the browser does not "refresh" until the entire perl script finished running which could last more than an hour. During this time only the dummy page is displayed and when the script is done, page1.html and page2.html get displayed and called each other. This is my sample script where sleep 30 simulates the long running process. Did I do something wrong?

#!/usr/bin/perl
#use HTML::Template;
#use CGI qw(:standard);
$| = 1;
if ($pid = fork)
{
sleep 30;
}
else
{
print "Content-type: text/html\n\n";
#print '<HTML>';
print '<HEAD>';
print '<META HTTP-EQUIV="Refresh" CONTENT="3; URL=/cgi_data/page1.html">';
print '<TITLE>New Site notification</TITLE>';
print '</HEAD>';
print '<BODY>';
print 'My homepage has moved to a new location. ';
print "I am here";
print '</BODY>';
print '</HTML>';
exit;
}

In reply to Client Pull Not Working correctly by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.