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

When putting a smiley right before a closing parenthesis, do you:

Use two parentheses: (Like this: :) )
Use one parenthesis: (Like this: :)
Reverse direction of the smiley: (Like this: (: )
Use angle/square brackets instead of parentheses
Use C-style commenting to set the smiley off from the closing parenthesis
Make the smiley a dunce: (:>
I disapprove of emoticons
Other