Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Re: reading output from another script

by Limbic~Region (Chancellor)
on Jul 23, 2003 at 22:05 UTC ( [id://277359]=note: print w/replies, xml ) Need Help??


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

NetWallah,
IO::Tee should be mostly OS independent. I however would have the tee printing to STDOUT and to a log. The reason I would choose a log versus a pipe to the other script is so the secondary script can be stopped and started at will without affecting the primary script. The input for the monitoring script would then use File::Tail to monitor the progress of the log. I guess the only thing then would to remember to set $| to auto-flush.

Cheers - L~R

Replies are listed 'Best First'.
Re: Re: Re: reading output from another script
by Octavian (Monk) on Jul 24, 2003 at 13:23 UTC
    Yeah, I would prefer if the data was written to a log file as well, it would make my life simplier and I wouldnt have needed assistance in figuring out a script to monitor it. However, this is not my script to maintain, I am not even sure what exactly it does, I was just approached with the problem they have, and asked if I could provide a solution. And sorry, yes I am running on an HPUX 11 system, however, there script is on a redhat linux box, but anything I write up should work on their machine. I know how tee works, but the problem is not that they want to see the output as it is being monitored, the problem is that they want to run the script, go home for the night, and if any problems occur, get a page about it. However, when I tried to write a script to watch for what they wanted, it wouldnt work until the input ended. So the end outcome would be that they wouldnt get the page until they came in in the morning and killed the script.
      Octavian,
      I do not see how this is possible without modifying the original script at least a little. When you use IO::Tee, you will be able to tie both the LOG and STDOUT to the same filehandle, so that wherever there is a print statement - it will print in both places. By setting auto-flush ($|), you will see events in the log as they happen (or pretty close). The script you write will have to use File::Tail to constantly be checking the bottom of the log looking for a specific event, which will trigger a desired action - such as email/page.

      I am not sure how to help beyond this without seeing the code of the original script, some sample output, and what "events" would like a trigger action.

      Cheers - L~R

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-03-29 13:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found