Perl - Logging to terminal from a long running system call -
i calling external program perl code using backticks
print `<some long running program>`
the long running program prints detailed log messages onto standard output. problem i'm having due buffering, output long running program printed @ once after has finished execution. tried making stdout filehandle "hot" did not help.
is there anyway can have program print continuously onto screen?
open exec pipe rather using backticks.
open ( $prog_stdout, "-|", "/your/program" ) or die $!;
this fork
, exec
give access $prog_stdout
things with.
e.g.
while ( <$prog_stdout> ) { print; }
(it'll close if external program exits, while
terminate).
you may want include autoflushing of filehandle. http://perldoc.perl.org/io/handle.html
but may not necessary, output won't buffered indefinitely.
Comments
Post a Comment