Click here to get back home

Perl:CGI - Creating a Please wait message

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Perl:CGI - Creating a Please wait message wjharrisiii 02-16-2007
Posted by wjharrisiii on February 16, 2007, 11:13 am
Please log in for more thread options


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


Posted by Petr Vileta on February 16, 2007, 11:36 am
Please log in for more thread options


>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!
>
Try to put
$| = 1; // switch to unbuffered output mode
at the begin of your script.
Many browser used to don't display content until receive needed bytes from
server. A little trick is to send to browser some spaces (0x20 character).
Browser must receive these spaces but show only one.

Example:

use strict;
$| = 1;
print "Content-type: text/html\n\n<head><body>\n<p>Please wait ...
processing your transaction";
my $time = 0;
while($time < 30)
{
print ' 'x1024;
sleep 2; # or do something other
$time++;
}
print " <b> - Done</b></body></html>\n";


--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)



Posted by Ice Man on February 16, 2007, 1:14 pm
Please log in for more thread options


88.838134.117810@v33g2000cwv.googlegroups.com...
>
> >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!
>
> Try to put
> $| =3D 1; // switch to unbuffered output mode
> at the begin of your script.
> Many browser used to don't display content until receive needed bytes from
> server. A little trick is to send to browser some spaces (0x20 character).
> Browser must receive these spaces but show only one.
>
> Example:
>
> use strict;
> $| =3D 1;
> print "Content-type: text/html\n\n<head><body>\n<p>Please wait ...
> processing your transaction";
> my $time =3D 0;
> while($time < 30)
> {
> print ' 'x1024;
> sleep 2; # or do something other
> $time++;
> }
> print " <b> - Done</b></body></html>\n";
>
> --
>
> Petr Vileta, Czech republic
> (My server rejects all messages from Yahoo and Hotmail. Send me your mail
> from another non-spammer site please.)

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D
I really appreciate your prompt reply! I have tried your suggestion
and flush does not occur until after the program completes. I tried
this
on the command line and it works like a charm however within the
browser it
does not. Any other suggestions?

$|
$OUTPUT_AUTOFLUSH
autoflush HANDLE EXPR
If set to nonzero, forces an fflush(3) after every write or print on
the currently selected output channel. (This is called "command
buffering". Contrary to popular belief, setting this variable does not
turn off buffering.) Default is 0, which on many systems means that
STDOUT will default to being line buffered if output is to the
terminal, and block buffered otherwise. Setting this variable is
useful primarily when you are outputting to a pipe, such as when you
are running a Perl script under rsh and want to see the output as it's
happening. This has no effect on input buffering. If you have a need
to flush a buffer immediately after setting $|, you may simply print
""; rather than waiting for the next print to flush it. (Mnemonic:
when you want your pipes to be piping hot.)

Thanks,
Bill


Posted by Randal L. Schwartz on February 16, 2007, 3:26 pm
Please log in for more thread options



wjharrisiii> I have created a CGI program which dynamically creates an HTML
wjharrisiii> FORM. This form upon submit, goes out and does some work that
wjharrisiii> can take up to 10 minutes to complete. Once done, the called CGI
wjharrisiii> provides the user with logged results.

<http://www.stonehenge.com/merlyn/LinuxMag/col39.html>

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

--
Posted via a free Usenet account from http://www.teranews.com


Posted by Ice Man on March 20, 2007, 1:19 pm
Please log in for more thread options


On Feb 16, 4:26 pm, mer...@stonehenge.com (Randal L. Schwartz) wrote:
>
> wjharrisiii> I have created a CGI program which dynamically creates an HTML
> wjharrisiii> FORM. This form upon submit, goes out and does some work that
> wjharrisiii> can take up to 10 minutes to complete. Once done, the called CGI
> wjharrisiii> provides the user with logged results.
>
> <http://www.stonehenge.com/merlyn/LinuxMag/col39.html>
>
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
> See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
>
> --
> Posted via a free Usenet account fromhttp://www.teranews.com

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


Similar ThreadsPosted
creating perl binary using PAR module , execution error under unix March 15, 2008, 7:06 am
Graphics Display Message board using Perl? May 18, 2007, 5:04 pm
Creating Calendar?? October 6, 2004, 12:37 am
Creating Thumbnails May 22, 2005, 5:18 pm
Question about creating modules May 27, 2006, 4:50 pm
Creating spokes with SVG::TT::Graph::Pie November 15, 2006, 4:29 pm
Creating FULLTEXT index OK on command line, but NOT with DBI...? March 12, 2005, 6:24 am
SOAP::Lite creating remote objects March 29, 2006, 9:51 am
Creating Makefiles for multiple nested modules June 8, 2006, 3:33 pm
Problem creating envelope-from in module Email::Send July 16, 2007, 7:33 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap