in reply to Command output to screen and logfile buffering problem

simple, don't use buffered IO, use sysread instead:
select STDERR; $| = 1; select STDOUT; $| = 1; open(CMD, 'perl b.pl 2>&1|') or die $!; open(LOGFILE, '>', 'b.log') or die $!; my $input; while(sysread(CMD, $input, 1024)) { print $input; print LOGFILE $input; } close(CMD);

just remember to always use sysread on CMD if you use it once

Replies are listed 'Best First'.
Re: Re: Command output to screen and logfile buffering problem
by eyepopslikeamosquito (Archbishop) on May 28, 2003 at 02:08 UTC

    Thanks. Works like a charm.