Wiggins d'Anconia wrote:
Chris Lyon wrote:
I seem to be erroring out @ the $session->login portion of my program
because the module that I am call is saying the password/username is
bad. How do I trap the error and exit cleanly without just dumping
from the application:
login failed: access denied or bad username at ./cisco.pl line 47
$session = Net::Telnet::Cisco->new(Host => $ip);
$session->login($login, $password);
You may want to check the 'errmode' method of Net::Telnet. Otherwise you
can catch the die in the normal Perl exception handling way,
perldoc -f eval
my $return = eval { # some code that might die };
if ($@) {
print "Uh oh, croaked leaving only: $@";
}
# code after not croaking
http://danconia.org
Personal experience says when you are doing the eval{} thing to make
sure you still have a way to die rather to the just keep plowing ahead.
As a practice, evaluate your $@ for errors you expect and then die on
all the others. This will give you a method for managing known errors
without ignoring the unexpected.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>