http://qs321.pair.com?node_id=277556


in reply to Re: Re: reading output from another script
in thread reading output from another script

In that case, the code I included above is exactly what you want.

As for 50 lines at a time - it's not really happening that way. The above loops will do things line by line as they are output. I bet it's just buffered output that is the problem.

You may have to unbuffer the original script (if it's perl, use the same solution - if it's not perl, I'm not sure what you can do). However, if it normally produces even output, then just fix the monitor.pl script.

You can unbuffer the output from your monitor.pl perl script with:
$| = 1;
or as an alternative
use FileHandle; STDOUT->autoflush;
This should produce smooth, line by line output, as it is generated by the original script.

As a side note, I bet your email gets sent immediately, it is just the text output to the screen that is buffered.

~Jon