Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: ssh connection lost during script running when box rebooted and script falls out...

by quester (Vicar)
on Jul 21, 2009 at 12:34 UTC ( #781940=note: print w/replies, xml ) Need Help??


in reply to ssh connection lost during script running when box rebooted and script falls out...

The easiest way to handle this would be to log off before the box shuts down, so it doesn't hang the ssh session. You could try replacing the shutdown command with this (untested):
(sleep 3; shutdown) & exit
You will want to change the sleep 2; call in your script to be considerably longer to give the remote system a chance to shut down, reboot and start up its ssh daemon. Or, better, enclose the last call to Net::SSH::Expect->new in a loop and retry it a reasonable number of times, sleeping a while between tries. This will let you connect reasonably quickly without dying if the remote system unexpected takes longer than usual to reboot (for example, if you are running SELinux and the /.autorelabel file exists.)
  • Comment on Re: ssh connection lost during script running when box rebooted and script falls out...
  • Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://781940]
help
Chatterbox?
belg4mit kicks Perl in the shins, "Unmatched ) in regex; marked by" my ass
[belg4mit]: Nothing wrong with perl -le 'print ":)" =~ /(?^u:^(\:|\:\))$) /'
[Lotus1]: belg4mit are you on a Linix server?
[belg4mit]: yes. the regular expression is generated in code from a text file. that s the regular expression that Perl blows up when it reaches it, but if I use it from the comman line it's fine
[belg4mit]: oh, wait, damn, different lne number
[choroba]: same Perl version?
[choroba]: oh, ok
[belg4mit]: I had \Q'd in one RE but not a subsequent one, doh

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2017-04-25 16:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (460 votes). Check out past polls.