BB_ has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to print HTML ("Please wait...") from a GCI script to entertain the user bored in front of his browser while the server is working on other tasks that take time. Once the server is done, I want to show the result screen on the browser (Thank you, goodbye...).

I tried the Merlyn approch with fork() and it craps. Win32 does not like the ActivePerl implementation of fork (oh by the way the server is a W2K box...). It causes Perl.exe to crash when one or the other "pseudo" process exits.

So if I want to launch a parallel process that will refresh the browser while the server is working and display a page while it's done....

PLEASE LET ME KNOW HOW CAN I DO IT...
-BB

Edited by footpad, ~ Fri Sep 27 06:11:16 2002 (UTC) : Removed <font> tags, per Consideration.

Replies are listed 'Best First'.
Re: If not fork(), then what ?
by runrig (Abbot) on Sep 27, 2002 at 00:11 UTC
    If you are using ActiveState perl (update: Ahh, I see you are), then Win32::Process is part of the standard distribution. You would create another perl process something like this:
    Win32::Process::Create(my($procobj), "C:\\Perl\\bin\\perl.exe", "perl C:\\path\\to\\another_perl_script.pl", 0, NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW, ".", # path to working directory ) or die ErrorReport();
    The third argument is supposed to be command line arguments, but for some reason you have to include 'perl' as well as any arguments. See the Win32::Process docs for the ErrorReport() function (which basically just regurgitates $^E).
      It works !

      Thanks. The adding of 'perl' to the command line does the trick.
Re: If not fork(), then what ?
by diotalevi (Canon) on Sep 26, 2002 at 23:23 UTC

    You can use the win32 module package and create processes the Windows way (CreateProcess). Please also reconsider your use of color next time - that red and green is atrocious to look at.

    Update: Fixed the link to go somewhere useful. It used to return zero results

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: If not fork(), then what ?
by hiseldl (Priest) on Sep 26, 2002 at 23:42 UTC
    As a work around, you could put a refresh in the page for every N seconds that refreshes to another CGI script. This script would check to see if your other script was finished and either return the 'results' page, or another refresh page. And, if your viewers need some eye candy, you can always put a javascript progress bar thingy on your page.

    The other alternative is to use frames where one frame is the 'controller' and the other frame is the 'document' that shows the results page. The controller page contains javascript that calls your 'are-your-results-ready' script every N seconds, and updates the 'document' page with either the results page, using the results CGI URL, or a 'please wait longer' message.

    --
    hiseldl
    What time is it? It's Camel Time!