View Full Version : Data between scripts
dan_c00per
04-03-2003, 11:56 AM
Hi,
I am writing a Perl script which contains a loop which can take a long time to complete, during each cycle, it calculates the percentage that has been completed, I also have a pop-up window which updates every few seconds, I want to be able to have the pop-up window display the percentage from the other script, is this possible? Can it be done via cookies? maybe a temp file?
Help ?!?
YUPAPA
04-03-2003, 11:52 PM
Cookie isn't necessary I think.
You may need a temporary file so that your script will write to there during each cycle.
You will need another script to display what's in the temp file too...
Another way of doing this is not to use temporary file. This can reduce a bit server load and you don't need the page to be refreshed. The script will just display the percentage during each cycle....
dan_c00per
04-04-2003, 09:09 AM
Tried the temporary file, but it won't read the contents of the file until the task is finished, even though I was closing the file during each cycle, and the browser doesn't update until the task is finished either.
YUPAPA
04-04-2003, 01:56 PM
You may want to try this
#!/usr/bin/perl
use CGI;
use FileHandle;
use strict;
my $cgi = new CGI;
autoflush STDOUT 1;
print "Content-Type: text/html\n\n";
print $cgi->start_html();
for (my $count=0; $count<=100; $count++) {
print "$count % Completed<BR>\n";
sleep 1;
}
print $cgi->end_html();
__END__
dan_c00per
04-04-2003, 02:08 PM
Tried it, but it still displays nothing until it has completed the script, then outputs the whole lot at once.
YUPAPA
04-04-2003, 04:15 PM
Are you sure?
It works fine to me... are you using IE?
What browser are you using?
dan_c00per
04-04-2003, 04:18 PM
I am using IE 5.2 Mac OS X
YUPAPA
04-04-2003, 04:24 PM
oh... it works with windoz i guess :o
cuz I have done the script before and some ppl viewed it with IE on mac o/s didn't work.
dan_c00per
04-04-2003, 04:29 PM
Just gave it a try on Windows XP and it works fine, most users will be using Windows, so it is perfect.
Cheers!
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.