473,395 Members | 1,677 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

CGI autoflush in Window

Hi:

I have the following script

==========================================

#!D:/Perl/bin/Perl.exe -w

use strict;
use CGI ":standard";
$| = 1;

my $MYFILE = "D:\\Apache\\logs\\mgmtwrkstn\\lucky.txt";

if (param("monitor")) {
&monitor();
} else {
if (fork) { # only need to fork for IE
print redirect(-uri => url() . "?monitor=yes",
-nph=>1);
} else {
&do_stuff();
}
sub monitor
{
my $html = &draw_page();

if (defined $html) {
print header(-refresh=>1, -nph=>1), $html;
} else {
print header(-nph=>1), &goodbye();
}
}
sub goodbye
{
return start_html(-title=>"Goodbye!") . h1("Goodbye!") .
end_html();
}
sub get_number
{
open NUMBER, "<$MYFILE" or return undef;
my $number = @glo;
close NUMBER;

return $number;
}
sub draw_page
{
my $number = &get_number();

return (defined $number) ? start_html(-title=>"Your Lucky
Number") . p("Your lucky number is $number.") . end_html() : undef;
}

sub do_stuff
{
for my $i (1 .. 10)
{
open NUMBER2, ">$MYFILE";
print NUMBER2 $i;
close NUMBER2;
sleep 1;
}

unlink $MYFILE;
}

================================================== =======

What this script essentially do is that it forks a child process to
write 1 to 10 on some file, while writing it, the parent process will
refresh the page every second to read the content of that file. This
script is orginally from
http://hypernews.ngdc.noaa.gov/Hyper.../1.html?nogifs

It works under Unix environment with apache. However, when I run this
script in W2K and apache 1.3.x. It doesn't work. It seems like that
the child process is locking the files its writing to and the parent
process can't go into it(even with autoflush on). Therefore, the
parent process doesn't refresh the page until the child process unlink
("delete") the file. Can anyone help me on this one? I am a newbie on
Perl and CGI and I want to continuosly monitor some background job on
a web page.

Thanks
Herman
Jul 19 '05 #1
0 2783

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Gianluca Trombetta | last post by:
How can i do the autoflush effect in a python cgi? In perl i know how do that but not in python... Can anyone help me? Thanks in advance Gianluca Trombetta
0
by: dede | last post by:
Dear community, having written a working example for using Semphores on a windows client, I created a little "server-application" that does the following: A Server continously "listens/tails"...
0
by: jabailo | last post by:
I was having some performance problems with a web service that is being called many times asynchronously. I was using a trace listener defined in the web.config and had autoflush=true. When I...
6
by: David Hayes | last post by:
juglesh <juglesh@nospamRadioKDUG.com> wrote in "Re: how to maximize the browser window that fits the monitor size?" (Saturday, January 01, 2005 3:12 AM): > > >I want to maximize the browser...
19
by: Darren | last post by:
I have a page that opens a popup window and within the window, some databse info is submitted and the window closes. It then refreshes the original window using window.opener.location.reload(). ...
14
by: D. Alvarado | last post by:
Hello, I am trying to open a window containing an image and I would like the image to be flush against the window -- i.e. have no padding or border. Can I make this happen with a single call to a...
1
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at...
26
by: yb | last post by:
Hi, Is there a standard for the global 'window' object in browsers? For example, it supports methods such as setInterval and clearInterval, and several others. I know that w3c standardized...
4
by: alexandre.brisebois | last post by:
Hi, I am using access 2003, I would like to know if there is an option to reorganize the tables in a maner that is readable, as we can do in sql sever 2000 or 2005. I have been given a database...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.