Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Net::Telnet: remote job completion

by Eliya (Vicar)
on Feb 28, 2012 at 10:37 UTC ( #956622=note: print w/ replies, xml ) Need Help??


in reply to Net::Telnet: remote job completion

It might be easier to modify the scripts such that they don't run in the background (though that of course depends on what exactly they're doing...).  In this case, you'd only have to wait for the prompt before starting the next script.

The other option (untested — as I have telnet service disabled here) would be to run tail -f (like you're doing interactively) and use waitfor() to scan for the "FINISHED" line in its output.  Some tails also support a --pid=<PID> option (in combination with -f) to have it automatically terminate when some other process (PID) dies or completes.


Comment on Re: Net::Telnet: remote job completion
Select or Download Code
Re^2: Net::Telnet: remote job completion
by maskull (Novice) on Feb 28, 2012 at 10:55 UTC
    Assuming I go with the waitfor() option, do I still have to pass $telnet->cmd("\cC") to force Ctrl-C on my tail command after each job? Have no way of testing it right now but I would assume so if I'm to get the prompt again.

      Yes.  In order to try, I installed telnetd in a sandbox, and it seems to work fine (i.e. ->cmd("\cC") actually does get a SIGINT being delivered to the tail -f).

      ... $telnet->print("/path/to/script") or die $telnet->errmsg; $telnet->print("tail -f /tmp/testxxx") or die $telnet->errmsg; $telnet->waitfor('/FINISHED/'); $telnet->cmd("\cC") or die $telnet->errmsg; ... (run next script)

      where script goes in the background and writes a few lines to /tmp/testxxx, with the last line being "FINISHED".

        Thanks! I'll go with this solution. The only problem I found is my timeout in waitfor() as the jobs can run for quite a while. I'll have to adjust for that.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (13)
As of 2014-07-25 20:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls