Perl:CGI - Creating a Please wait message

Discussion in 'Perl Misc' started by Ice Man, Feb 16, 2007.

  1. Ice Man

    Ice Man Guest

    I have created a CGI program which dynamically creates an HTML FORM.
    This form upon submit, goes out and does some work that can take up
    to
    10 minutes to complete. Once done, the called CGI provides the user
    with logged results.
    My goal is to provide the user with an automated GIF and a message to
    please stand by while the program is out doing its work.

    I have tried to first display this "Please wait ... processing your
    transaction" message at the beginning of the called CGI called
    program, before any work is done. I have also tried to call an
    intermediary CGI program which displays the message and calls the
    working CGI in the background.

    In all cases, the message is not displayed until after the CGI
    working
    program [which takes 10 minutes to complete] has actually completed!

    I do not have a large javascript background and I would prefer to
    stay
    in Perl native. Is there anything I can do here or is my only option
    to learn javascripting?

    Thanks,
    -Bill
    Ice Man, Feb 16, 2007
    #1
    1. Advertising

  2. Ice Man

    J. Gleixner Guest

    Ice Man wrote:
    > I have created a CGI program which dynamically creates an HTML FORM.
    > This form upon submit, goes out and does some work that can take up
    > to
    > 10 minutes to complete. Once done, the called CGI provides the user
    > with logged results.
    > My goal is to provide the user with an automated GIF and a message to
    > please stand by while the program is out doing its work.


    [...]

    http://www.stonehenge.com/merlyn/WebTechniques/col20.html
    J. Gleixner, Feb 16, 2007
    #2
    1. Advertising

  3. Ice Man wrote:

    > I have created a CGI program which dynamically creates an HTML FORM.
    > This form upon submit, goes out and does some work that can take up
    > to
    > 10 minutes to complete. Once done, the called CGI provides the user
    > with logged results.
    > My goal is to provide the user with an automated GIF and a message to
    > please stand by while the program is out doing its work.
    >
    > I have tried to first display this "Please wait ... processing your
    > transaction" message at the beginning of the called CGI called
    > program, before any work is done. I have also tried to call an
    > intermediary CGI program which displays the message and calls the
    > working CGI in the background.
    >
    > In all cases, the message is not displayed until after the CGI
    > working
    > program [which takes 10 minutes to complete] has actually completed!
    >
    > I do not have a large javascript background and I would prefer to
    > stay
    > in Perl native. Is there anything I can do here or is my only option
    > to learn javascripting?
    >
    > Thanks,
    > -Bill
    >


    10 minutes? you might store the result set in a file and send it (or a link to
    it) via email to the user. you also run the risk of timing-out your web-server
    as well as the browser...


    --
    Michael Austin
    Database Consultant
    Domain Registration and Linux/Windows Web Hosting Reseller
    http://www.spacelots.com
    Michael Austin, Feb 17, 2007
    #3
  4. Hi, Bill!

    > Is there anything I can do here or is my only option
    > to learn javascripting?


    Javascripting won't help you. Try forking like this in your CGI script:

    my $pid;
    if (!defined ($pid = fork)) {
    # This is executed when the forking did not work
    # Output an error message.
    }
    elsif (! $pid) {

    # this is the branch for the child process

    close(STDIN);
    close(STDOUT);
    close(STDERR);

    # Do long running stuff here

    # Then replace the temporary result file
    }

    # this is the branch for the parent process
    # Output a temporary result file (index.html)
    # with "please wait blabla" here.

    # Then

    print "Location: $temporary_response_file\n\n";

    exit;

    I hope it works for you.

    Marco.
    Marco Neumann, Feb 17, 2007
    #4
  5. > I hope it works for you.

    Ups just noticed: Insert this into the head of your temporary output file:

    <head>
    <meta HTTP-EQUIV="refresh" CONTENT="30">
    <meta http-equiv="Pragma" content="no-cache">
    </head>

    This will make it reload every 30 seconds until the child process outputs
    the final result file.

    Cheers,
    Marco.
    Marco Neumann, Feb 17, 2007
    #5
  6. Ice Man

    Ice Man Guest

    On Feb 17, 2:21 pm, "Marco Neumann" <> wrote:
    > > I hope it works for you.

    >
    > Ups just noticed: Insert this into the head of your temporary output file:
    >
    > <head>
    > <meta HTTP-EQUIV="refresh" CONTENT="30">
    > <meta http-equiv="Pragma" content="no-cache">
    > </head>
    >
    > This will make it reload every 30 seconds until the child process outputs
    > the final result file.
    >
    > Cheers,
    > Marco.


    Actually This helped out a lot. I got the following link from another
    group
    which is actually a great example! Appreciate your response and sorry
    for
    my late reply:

    http://www.stonehenge.com/merlyn/WebTechniques/col20.html

    -Bill
    Ice Man, Mar 20, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Craig Deelsnyder

    Re: best way to do a "please wait" message

    Craig Deelsnyder, Aug 3, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    786
  2. A.M

    Please Wait ... message

    A.M, May 11, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    484
  3. Replies:
    2
    Views:
    544
  4. Milo Thurston

    CGI "please wait" message.

    Milo Thurston, Jun 3, 2004, in forum: Ruby
    Replies:
    5
    Views:
    414
    Georgy
    Jun 5, 2004
  5. kath
    Replies:
    4
    Views:
    565
    J. Gleixner
    Apr 9, 2007
Loading...

Share This Page