When this script is triggered to run, its function is to login to our Cisco dialup router, make a dial up call to a remote router modem, login to the remote router, run some Cisco commands, and then send an XML formatted email to our ticketing system including the output from the commands it runs. Problem we are running into is if the Cisco dialup router does not make a successful connection to the far end router modem, the script does not send the email to our ticketing system. It seems the script must hang or just not complete at that point. If a success modem connection is made with the far end modem the script completes and the email is sent to ticketing system. This inherieted perl code and the original author is no longer reachable. This is section that makes the connection to the dialer and then makes the call to the far end modem. It seems that if it hits the timeout value in the if eval statement it does not proceed.
if ( $intcount>0 && $circid[0] ne "Not Defined" && $modemnumber ne "No +t Defined" && $modemdown eq "0") { #Create the connection to the NAS $session = Net::Telnet::Cisco->new(Host => $nashost, Port => $nasp +ort, Input_log => $logfile, Dump_Log => $dumpfile); # Login to the NAS and dial the OOB modem $session->waitfor('/Username:.*$/'); $session->print($nasuser); $session->waitfor('/Password:.*$/'); $session->print($naspass); $session->waitfor('/^$/'); $session->print("ATZ"); dial: if ($session->waitfor('/OK$/')) { $session->print("ATDT 91".$modemnumber); # Check for a connected status if (eval { $session->Net::Telnet::waitfor(Match => '/Username: +.*$/', Timeout => '60', Errmode => 'die'); 1 }) { if ($session->login(Name => $nasuser, Password => $naspass +)) { @command1 = "Interface Commands Output"; my $i = 0; while ($ifname[$i]) { push(@command1,("\n\n$caption>sh int $ifname[$i]\n +")); push(@command1,$session->cmd("sh int $ifname[$i]") +); $i++; } @command2 = "Routing Commands Output"; if ($wan eq "PIP") { push(@command2,("\n\n$caption>sh ip route\n")); push(@command2,$session->cmd("sh ip route")); push(@command2,("\n\n$caption>sh bgp summary\n")); push(@command2,$session->cmd("sh bgp summary")); push(@command2,("\n\n$caption>sh bgp\n")); push(@command2,$session->cmd("sh bgp")); } else { push(@command2,("\n\n$caption>sh ip route\n")); push(@command2,$session->cmd("sh ip route")); push(@command2,("\n\n$caption>sh ip ospf\n")); push(@command2,$session->cmd("sh ip ospf")); push(@command2,("\n\n$caption>sh ip ospf neigh\n") +); push(@command2,$session->cmd("sh ip ospf neigh")); } $session->close; $dialfailed = 0; } } } }
I can include more of the script if helpful, I just did not want to assume and paste the entire script (about 350 lines). Thanks in advance.
In reply to If unsuccessful action by fasteddye
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |