The impression I get from your description here is different from what I got out of our conversation on the ChatterBox. For one, you never said you had access to the source of the CGI script you want to change the output from. I assumed that that page came from the outside world. So it's an entirely different kettle of fish, now.

Anyway, I've given this some thought, and I must say that your solution seems a bit, er, user-unfriendly. I would think of a more sofisticated solution, completely automatic, and more deeply entwined with the original script. That might pose some problems on the collaboration level with your vendor, because the easy solution to do that, would be to modify the original script.

What I would attempt, is to let the running of the data fetching script be triggered by the loading of that page. In order for it to be efficient, you'll have to tweak the whole system a little. For example, you might not want this script to run more than once every five minutes or so, depending on how long a run takes, and how resource-hungry it is. So it would need to leave a timestamp mark of the "last run" somewhere, and your launcher script could check that before even firing it up. Another valid test could be to check first if any new data has come in. If not, you can skip the run entirely. This means the system has to be tweaked to set a flag (or a timestamp marker) everytime new data does come in. I think you get the picture by now...

How can you make this as unobstrusive as possible? If your script runs on the same machine as the original CGI script, just start up the external script with a system() call, or with one of the more elaborate (double) fork schemes, exec, etc. in the CGI script.

If it doesn't run on the same machine, make your launcher script a CGI script that outputs a 1-pixel transparent GIF (just copy the contents of such an image to STDOUT — with an appropriate content-type header, of course), and place that image in the HTML page. It's a trick web that stat counters often use.

--
bart


In reply to Re: CGI Question - run external script and then update page by bart
in thread CGI Question - run external script and then update page by Limbic~Region

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.