Solved

perl send processing page

Posted on 2002-07-26
2
193 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
instmodsh - listing perl modules 2 74
Migrate OTRS to newest version. 1 312
Union rows in array that have common elements (Part 2) 4 70
Export Variables in Perl 3 46
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…
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…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

861 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

24 Experts available now in Live!

Get 1:1 Help Now