Many thanks to $Bill, Carl and Michael,

The cause was the buffering in the executable involved,
I had the coder insert fflush(stdout) after each printf statement.
Also my understanding on buffering has somewhat improved.
Thanks again.

|__
| Mark Zvolanek
| +612 9227 0479



-----Original Message-----
From: $Bill Luebkert [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 5 December 2000 15:08
To: Mark Zvolanek
Cc: '[EMAIL PROTECTED]'
Subject: Re: process output pipe autoflush


Mark Zvolanek wrote:
> 
> Hello,
> 
> I have a problem with autoflush. Platform is Windows NT 4 / sp6.
> 
> I use the following code:
> 
> $command = 'executable.exe param1 ';    #option 1
> # $command = 'DIR C:\ /S';              #option 2
> open (PIPE, "$command |");
> $| = 1;
> while (<PIPE>){
>         print;
> }
> 
> If I use line with (option 2) the output does not get buffered as
expected.
> If I use line with (option 1) the output of the executable is buffered.
> 
> If I execute the line "executable.exe param1" on the DOS prompt
> the oputput is produced immediately.
> I tried both autoflush PIPE and select((select(PIPE), $| = 1)[0])
commands,
> I even print out the value of $| during execution, it is set to 1.
> 
> What am I doing wrong?

How do you know the data is being buffered or not?

Are you doing this under CGI conditions?

Do you understand what buffering does?

It basically forces each line out individually (when $| is set) rather 
then waiting for an internal buffer (maybe 512/1024 bytes??) to fill before 
outputting.  Leaving STDOUT buffered ($| not set) is more efficient.

If you were to slip a sleep 1 into your loop, you would see the result 
since one would print one line every second and the other would wait several

seconds and then print several lines.

-- 
  ,-/-  __      _  _         $Bill Luebkert   ICQ=14439852
 (_/   /  )    // //       DBE Collectibles   http://www.wgn.net/~dbe/
  / ) /--<  o // //      Mailto:[EMAIL PROTECTED]   http://dbecoll.webjump.com/
-/-' /___/_<_</_</_    http://www.freeyellow.com/members/dbecoll/
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to