The catch is that you always have to return something,
even if that something is "nothing". Some sites feature
a waiting page which refreshes frequently, waiting on output
from something. It might feature a pleasant animated GIF,
and hopefully not something along the lines of
WAIT
with the horrific <BLINK> tag.
A quick way of doing this is to create script A which,
when run the first time will fork off script B, and then
refresh to itself with a special parameter. Script B
will write to a certain filename in /tmp, for example,
and script A, when called, will check for this file. When
this file is there, script A prints it, possibly deletes
it, and stops refreshing. The name of the file is encoded
in the special parameter. If, for example, the parameter
"_" was set to "fZdaPXzAQ", then you would be waiting for
the file "/tmp/fZdaPXzAQ.out". The choice of name is
arbitrary.
There are a couple of things you will want to note:
- You might want to write a separate program to clean
out any stale /tmp entries instead of leaving this up to
script A. This way the user can reload the page and still
get output, without you having to process all over again.
- Your script B should not write directly to the /tmp
file, but should create a preliminary version which it
writes to, then renames it at the end to the proper name.
This will prevent script A from jumping the gun and printing
when script B has only written half its output.