Unfortunately, no. Ends up being we need to place the $ssh->cmd() within an eval block. Net::SSH::Perl was designed to die() if the connection attempt fails.
I was hoping to avoid an eval block as I really don't like them because they require a recompilation each time we encounter an eval block. As the camel book says, it is a performance hit.
eval { ($stdout, $stderr, $exit) = $ssh->cmd("df -k $dump_dir"); }; if ($@) { print "SSH Connection attempt failed\n" if ($@ =~ m/Permission denied/i); }
The login() method doesn't do anything but set the settings for the connection.. It doesn't actually connect to anything.
Jason L. Froebe
No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1
In reply to Re^2: how to handle login failures with Net:::SSH::Perl?
by jfroebe
in thread how to handle login failures with Net:::SSH::Perl?
by jfroebe
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |