Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Re: Re: reading output from another script

by jmanning2k (Pilgrim)
on Jul 24, 2003 at 14:39 UTC ( #277556=note: print w/replies, xml ) Need Help??


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

Replies are listed 'Best First'.
Re: Re: Re: Re: reading output from another script
by Octavian (Monk) on Jul 24, 2003 at 16:59 UTC
    good idea with the autoflush idea, however it doesnt appear to fix it. Here are my findings:
    I have a test program that dumps look-alike output to the screen for development of this script...I call it test...so I do a
    ./test |./monitor.pl
    For testing I have it dump 9 lines, sleep for a second, then dump 9 more, and so on...when I run it through the monitor script, about every 5 seconds it dumps a big chunk to the screen. if I reduce it to dump 1 line, sleep for 1..then it takes longer...not exact numbers here, but it looks like it dumps the same number of lines in big chunks, just it takes longer to do...prob about 30 seconds or so...I changed it to dump 1 line and then sleep for 10, and guess what....the monitor script is now taking FOREVER to dump anything....if it was just a matter of the screen not being able to catch up with it, I could understand, but why, if the perl script is handling it in real time, would it take so long for the print to come out?
    Its no big thing, the script they wanted me to monitor dumps so fast that it proccesses the chunk in about 5 seconds or so, so I dont NEED to have this riddle solved for me, but it is a big stumper for me and if anyone knows the answer to this new problem that would be cool ;)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://277556]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (1)
As of 2022-01-28 04:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (73 votes). Check out past polls.

    Notices?