Re: [Ssh-sftp-perl-users] help with login failure and perl script exiting.
Brought to you by:
dbrobins
|
From: Nick E. <Nic...@pg...> - 2006-08-10 16:11:53
|
Hi David,
I had the exact same issue.
Not knowing Perl very well, I looked up error handling on google and
found that if I wrap BOTH the "new" mehod and the "login" function in an
"eval {}" block, the script will just stuff the errors into the @_
variable..
eval { $ssh = Net::SSH::Perl->new("$hostname"); };
if($@) {
print "Got an error, skipping this host";
<add what you want to do>
}
eval { $ssh->login("me","pass"); };
if($@) {
print "Got an error, skipping this host";
<add what you want to do>
}
Hope this helps :)
Nick
Nick Ellson
Infrastructure Specialist
PGE, Network Operations Center
Personal: (503) 464-2995
Network Trouble: (503) 464-8754
"Educating Layer 8, one user at a time."
>>> "Mark Funk" <mf...@tr...> 08/10/2006 7:28:47 AM >>>
Hello Folks,
I have over 800 Cisco Routers that I need to ssh into.
I do a socket connection test to skip any routers that are not
listening on
port 22,
But if the logon authentication fails, then my perl script exits.
I would like to log it and move on..
Does anybody have some code samples that logs failures and continues
without
exiting the perl script?
Thanks in Advance,
(Thanks Eric, I think this is working now!!)
David M. Funk
President/CEO
Tivoli Certified Enterprise Consultant
Specializing in Network and Systems Management Solutions
Trinity Solutions
604 Cassandra Dr.
Cranberry Twp., PA 16066
Phone: 724-316-0721
Fax: 724-772-7889
email: mf...@tr...
http://www.trinitysol.net
|