Perl:CGI - Creating a Please wait message

I

Ice Man

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
 
M

Michael Austin

Ice said:
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...
 
M

Marco Neumann

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.
 
M

Marco Neumann

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.
 
I

Ice Man

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,227
Latest member
Daniella65

Latest Threads

Top