You need to run the long running function in the background, so the CGI script will terminate right away. This way, the <meta http-equiv="refresh" ... will also be sent right away, independently of any buffering that might happen on the way from the CGI script/webserver to the browser... and the browser will then request some-html-file after the specifed period (which, btw, should be at least 4 minutes (if the function call takes that long), not 2 secs...).

In case the webserver is Apache running on something unix-ish, you'd fork (and if needed exec) a child process to run something in the background. But don't forget to close (or redirect to file) STDOUT and STDERR in the child before you start the long running task. Otherwise Apache will wait on the other end of the pipes setup to the CGI process until both the parent CGI and its child have closed the handles — meaning the initial request would wait/hang for as long as the function call runs (STDIN doesn't need to be closed, because Apache is on the sending side of the pipe and closes itself).


In reply to Re^3: Running CGI script within another cgi script by almut
in thread Running CGI script within another cgi script 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.