Forum Moderators: coopster & phranque

Message Too Old, No Replies

Slow CGI script prints a temporary message?

         

docaj

10:03 pm on Feb 25, 2005 (gmt 0)



Hi, I have a perl CGI script that runs very slow and often takes 10 seconds to print the output. I want to display a message like "Please wait while the program is running" to web users. How can I implement that?
Thank you very much!

Moby_Dim

8:02 pm on Feb 26, 2005 (gmt 0)

10+ Year Member



Just a simple idea (have not tried myself.)

Make a simple static page with the temp. message you wish, and insert SSI (exec cgi) below.

Moby_Dim

8:10 pm on Feb 26, 2005 (gmt 0)

10+ Year Member



hm-m, in this case the message remains on the page forever...

well, the message could be implemented in javascript, for example, fading after X seconds.

An interesting puzzle after all ;)

rocknbil

6:05 pm on Feb 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If it's running that slow, something is wrong, unless it's searching text files.

There are a couple answers (that I know of,) but they are complicated and beyond the scope of explanation on a message board. One way that works is by by forking a process, getting the PID, and checking it periodically from the browser using the PID as a handle. Another is server push, the old animation method before animated gifs. Sorry not to be of more help, but like I say the ones I know of are difficult to explain.

Matt Probert

7:38 pm on Feb 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a perl CGI script that runs very slow and often takes 10 seconds to print the output. I want to display a message like "Please wait while the program is running" to web users. How can I implement that?

We implemented just this, so as to prevent people sending multiple requests and overloading the server....

Use two scripts.

Script A, stores the parameter string passed in a variable (here I am using $qs), and then uses the REFRESH meta tag to call a second script.

Within <head> and </head> include:

print "<meta http-equiv=\"Refresh\" content=\"1; URL=mysite.com/myscript2.pl?$qs\">\n";

Then within the <body></body> display a please wait message:

print "<h1 align=center>Your search is being processed.</h1>\n";
print "<p><h1 align=center>Please Wait...</h1>\n";

The second (real) script then gets automatically called (by most but not all browsers) via the refresh directive, and when it eventually finishes replaces whats on the screen.

Note: The Refresh meta tag does not work with ALL browsers, but it was the best solution we could find.

Matt

SeanW

4:58 am on Mar 1, 2005 (gmt 0)

10+ Year Member



Do server pushes still work these days? Since we're in the Perl forum, CGI::Push seems to implement it.

Sean