in reply to Net::SSH::Perl, Net::SSH::Expect crashes script if host is unreachable
Net::SSH::Expect sets up a timeout handler, which croaks (i.e. dies, stopping the script) in case it gets called:
# line 207 [ timeout => sub { croak SSH_AUTHENTICATION_ERROR . " Login timed ou +t. " . "The input stream currently has the contents bell +ow: " . $self->peek(); } ]
So, wrap the login call in an eval { } block (Perl's way of catching exceptions), e.g. like this:
eval { $loginOutput = $ssh->login(); }; if ($@) { myAuditLog(LOG,"Login has failed: $@"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Net::SSH::Perl, Net::SSH::Expect crashes script if host is unreachable
by Anonymous Monk on May 08, 2012 at 13:57 UTC | |
by mlebel (Hermit) on May 24, 2012 at 15:07 UTC |