in reply to Net::Telnet error trapping
I know this is an old question but I ran into the same issue and could not find the answer...
As far as I can tell, the error basically tells you that the "open" command was not successful and you are still trying to execute functions anyway (e.g. login, cmd). Below is a code snippet that should prevent this error in the future:
my $t = new Net::Telnet (Timeout => '30', Errmode => 'return', ); my $openResult = $t->open("$remoteHost"); if ($openResult eq 1){ my $loginResult = $t->login($username, $password); if ($loginResult eq 1){ @lines = $t->cmd("your_command_here"); } else { $lines[0] = "Error logging into device: '" . $t->errmsg . "' \n" +; } $t->close; } else { $lines[0] = "Error connecting to device: '" . $t->errmsg . "' \n"; }
|
|---|