Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
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?
[erix]: still doesn't work?
[afoken]: sorry, forget File::BOM. I did not see DBD.
[ELISHEVA]: perldoc - of course
[erix]: hm, where's tux when you need him?
[ELISHEVA]: what's curiouser is that the underlying Text::CSV_XS appears to be BOM-friendly
[afoken]: DBD::CSV has a csv_class attribute. You could subclass Text::CSV_XS to handle BOMs, e.g. through File::BOM.
[ELISHEVA]: Text::CSV_XS already can handle boms - see its detect_bom flag
[ELISHEVA]: but it seems that the DBD::CSV layer on top of it doesn't
[afoken]: Also: All other attributes that start with csv_ and are not described above will be passed to Text::CSV_XS (without the csv_ prefix).
[Discipulus]: what about a good 'ol SOPW?

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2017-05-28 20:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?