Im having an issue with a perl script im trying to run. The script runs through a list of routers and performs a "show interfaces descriptions" command at the command prompt and returns the value. For some reason i get the below error. I think it has something to do with Net::Telnet::Cisco but im not exactly sure. I can manually log into each router individiually but when i run the script, it fails.

print "Device list containte in the device.list file will be a CSV fi +le\n\n"; print "The device.list file will consist of only the device OS and cat +egory \n"; print "This script works on CISCO routers.\n\n"; print "Enter username:\n"; $username = <STDIN>; chomp $username; print "Enter password:\n"; $password = <STDIN>; chomp $password; print "Enter the command you want issued:\n"; $cmd = <STDIN> ; chomp $cmd; print "Enter the string you want to search for:\n"; $string = <STDIN>; chomp $string; print "\n\n\n"; #print "password is -$password-\n"; #print "username is -$username-\n"; #print "command is -$cmd-\n"; #print "search string is: -$string-\n"; use Net::Telnet::Cisco; open (DEVICE, 'device.list'); while (<DEVICE>) { chomp; $routerIP = $_; print "Router IP is $routerIP,"; my $session = Net::Telnet::Cisco->new(Host => "$routerIP", Input_log=> +"input.log", ); $session->login("$username", "$password"); my @output = $session->cmd("$cmd"); for $_ (@output) { #BRACKET A my $statline = $_; chomp $statline; if ($statline =~ /($string)/) { #Bracket B print "$statline"; } # end Bracket B } print "\n"; } exit;


after running the script i get this error:

bash-2.03$ perl CiscoCE_CMD_Query.pl Device list containte in the device.list file will be a CSV file The device.list file will consist of only the device OS and category This script works on CISCO routers. Enter username: XXXX Enter password: XXX! Enter the command you want issued: sh int des Enter the string you want to search for: RNC Router IP is ,login failed: access denied or bad username at CiscoCE_C +MD_Query.pl line 31

In reply to Problems with Cisco Router Perl Query by Tanto4545

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.