What I would do for something like that is:

1) Write a program which actually does the processing. This program should be completely independent of the CGI/web environment and able to be run from the command line, from cron, or from anywhere else. Output is written to either a database or a text file, depending on its complexity and what needs to be done with it.

2) Write a CGI interface which, when called, checks to see whether the program from #1 is already running and starts it up - still running as a separate, non-CGI process - if it isn't. Once the #1 program is running, grab its output and display it as a web page.

Putting the actual processing activity outside of the CGI environment is important if you want the person who originally starts the processing to be able to close their browser without aborting any remaining processing. It also has the side benefit that, if (when...) you someday want it to just run automatically whether anyone is watching or not, then you can set up a cron job to do just that instead of requiring someone to manually initiate it and then wait for it to complete.


In reply to Re: Stream or Broadcast Output from CGI script by dsheroh
in thread Stream or Broadcast Output from CGI script by stickman

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.