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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.