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