Greetings,

I have the strangest of problems I just can't seem to be able to get my
head around.  Bear with me while I try to define it as its a little
strange.

I have a perl CGI proggie (henceforth known as proggie1) which when
executed executes another perl proggie (henceforth called proggie2).

Proggie2 does "stuff" and outputs to its STDOUT a status of how its
doing.

Proggie1 reads in this output and transforms it into something vaugly
presentable.

We want the entire process to be unbuffered such that the browser can be
used almost like tailing a logfile.

Webserver and a single perl process play nicely with this... eg:

#!/usr/bin/perl
$| = 1;
print("Content-type: text/html\n\n");

foreach my $foo qw(1 2 3 4) {
        print("$foo: I like Pie!<br>\n");
        sleep 3;
}

So, the webserver and the perl cgi script here play lovely.


So, write a simple proggie to do this without the mime rubbish and
provide a timestamp like so...

#!/usr/bin/perl

$| = 1;

foreach my $pie (qw(1 2 3 4 5 6)) {
   print("time printed\(".time()."\)".$arse." I like buffy, not
buffers\n");
   sleep 2;
}



Then a CGI script to call it, read and display what it gets...

#!/usr/bin/perl
$| = 1;
use IPC::Run qw(start finish);

print("Content-type: text/html\n\n");

$h = start ["/usr/httpd/cgi-bin/proggie2"], '<pipe', \*IN, '>pipe',
\*OUT;
close(IN);
my $x;

while ($x = <OUT>) {
   print("time recieved(".time()."$x<br>");
}

finish $h;


It buffers... Ie, I get the entire lump of textual output at the time
that the process exits.

Example output is:

time recieved(1049294103time printed(1049294103) I like buffy
time recieved(1049294105time printed(1049294105) I like buffy
time recieved(1049294107time printed(1049294107) I like buffy
time recieved(1049294109time printed(1049294109) I like buffy
time recieved(1049294111time printed(1049294111) I like buffy
time recieved(1049294113time printed(1049294113) I like buffy

Ie, the CGI script *is* outputting the lines as its recieving
them.

Running the CGI script directly from the command line means no
buffering.  Telnetting directly to port 80 confirms that its not browser
behaviour.

Does anyone have any clue as to what could be going on here?

Thanks,


Red

-- 
Redvers Davies <[EMAIL PROTECTED]>
Critical Integration Ltd.


Reply via email to