in reply to print output from system command in real time

You could try something like
open SYS, "command |" or die "$!"; while (<SYS>) { print } close SYS;
but a lot depends on whether 'command' buffers its output, among other variables. You should probably read perldoc perlipc for more insight.

Replies are listed 'Best First'.
Re^2: print output from system command in real time
by boat73 (Scribe) on May 10, 2005 at 18:53 UTC
    Thanks but that did not work. I built a standalone exe from the following code. Oh and I am doing this on windowz to make it even more fun.
    until($cnt == "100"){ print "COUNT IS $cnt\n"; sleep 5; $cnt++; }
    I then call the exe within perl. With the code you supplied it still waits until completion before printing. I even tried setting autoflush with the code below.
    open SYS, "c:\\temp\\junk.exe |" or die "$!"; $oldfh=select(SYS); $| = 1; select($oldfh); $| = 1; while (<SYS>) { print } close SYS;
        Hmmm, the problem is that the exe I am truly running does the same thing and I am unable to modify that code. System didn't work, still waits til completion to print.