Solved

perl send processing page

Posted on 2002-07-26
2
181 Views
Last Modified: 2010-03-05
I am trying to write a PERL script which does quite a bit
of processing before it displays anything to the browser.
I want to send to the browser a message like "Working on your
query" while the processing is happening.  Does anyone know
of a trick or tip to send HTML code to the browser while
processing is taking place?

I have found some comments on the web,
saying I should do $|=1 to to bypass script buffer,
and I need to bypass web server buffer too.  I am using
apache server 1.3.

Can somebody give me a working example?
Thanks.

0
Comment
Question by:xiaoxiangz
2 Comments
 
LVL 6

Accepted Solution

by:
sstouk earned 140 total points
ID: 7181083
Perhaps you will find my example useful:

#!/usr/local/bin/perl
use CGI qw(:standard);
$|=1;
$cgi = new CGI;
$ACCESS_PATH = &GET_SCRIPT_FULL_PATH . "?p=1;";

print $cgi->header;
print " <html>";
print "<head>";
print "<title>$TAG_WEBTITLE. Version: $VERSION_NUMBER</title>";
print "   <meta http-equiv=\"Content-Type\" content=\"html\"; charset=\"$TAG_CHARSET\">";
print "   <meta name=\"Author\" content=\"Sergy Stouk\">";
print "   <meta name=\"GENERATOR\" content=\"Mozilla/4.74 [en] (Windows NT 5.0; U) [Netscape]\">";
print "</head>";
print "<body>";

print "Please Wait ... processing Your data...";

if (param('p'))
{
# Emulating Processing of Data;    
     for ($i=0;$i<10;$i++)
     {
     sleep(1);
     };
print "Welcome... Your Data is processed...";    
} else {
     print "Please Wait While Directing to a new Page.....";
     sleep(3);
     J_LOCATION($ACCESS_PATH);
     };
print "</body></html>";
exit;

sub J_LOCATION
{
print qq{ <SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
         <!--
         window.location.replace("};

print "$_[0]";

print qq{")
         // -->
         </SCRIPT>
         };
};

sub GET_SCRIPT_FULL_PATH
{
my($temp) = undef;
my($LOCAL_ADDR) = undef;
my($SCRIPT_NAME) = undef;
my($SCRIPT_PATH) = undef;
my($SCRIPT_FULL_PATH) = undef;
$LOCAL_ADDR= $ENV{"SERVER_NAME"};
$_= $ENV{"SCRIPT_NAME"};
($SCRIPT_PATH,$SCRIPT_NAME) = /(.*)\/(.*)$/;
$SCRIPT_FULL_PATH = "http://$LOCAL_ADDR"."$SCRIPT_PATH"."/"."$SCRIPT_NAME";
return $SCRIPT_FULL_PATH;
};

0
 

Author Comment

by:xiaoxiangz
ID: 7181216
It works.

#!/usr/local/bin/perl
use CGI qw(:standard);
$|=1;
$cgi = new CGI;
 
print $cgi->header;
print " <html>";
print "<head>";
##Strange, If I remove any meta statement, it doesnot work
print "   <meta http-equiv=\"Content-Type\" content=\"html\"; charset=\"$TAG_CHARSET\">";                                        
print "   <meta name=\"Author\" content=\"Shane Zhang\">";
print "   <meta name=\"GENERATOR\" content=\"Mozilla/4.74 [en] (Windows NT 5.0;
U) [Netscape]\">";
print "</head>";
print "<body>";
 
print "Please Wait ... processing Your data...<br>";
 
# Emulating Processing of Data;    
    for ($i=0;$i<10;$i++)
    {
    sleep(1);
    print "step " . $i. "<br>";
    };  
print "Welcome... Your Data is processed...";
print "</body></html>";
exit;
 
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now