in reply to
Re: Net::OpenSSH fastest way to reconnect to a rebooted machine?
in thread Net::OpenSSH fastest way to reconnect to a rebooted machine?
What you've described is exactly what I'm trying to figure out how to do. The question is how do I test that the connection has either succeeded or failed? I tried this, since the Net::OpenSSH documentation says that a failure returns undef or an empty list:
$ssh{$host} = Net::OpenSSH->new($host, master_opts => [-i => "/path/t
+o/key"]);
if(defined $ssh{$host}) {
print STDOUT "SSHD is back up. Continuing...\n";
}
else {
print STDOUT "Still waiting for SSH. Retrying in 5 seconds...\n"
+;
sleep 5;
}
This fails though. Apparently the "no route to host" message that comes back from the failed connection attempt is enough to define $ssh{$host}. What's a good way to test to see if the connection is successful?