Solved

perl send processing page

Posted on 2002-07-26
2
219 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
Six Sigma Control Plans

728 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