use Net::Telnet::Cisco;
use strict;
use warnings;
use diagnostics;
my %users = ("6" =>"none", );
my %pwds = ("6" =>"thispass", );
my $i = 4;
for ($i; $i <= 10; $i++){
my $device = "10.10.$i.1";
my $pe = $i;
my $curpwd = "admin";
if (defined $pwds{$i}) {
$curpwd = $pwds{$i};
}
if ($users{$i} eq "none") {
my $session->login(Password => $curpwd);
} else {
my $session->login(Name => 'admin', Password => $curpwd, Input_log => "perllogrouter/router$i.log",);
}
$session->cmd ("sh running-config | redirect ftp://192.168.1.10/proba$pe.txt");
$session->close;
}
####
C:\Users\mydesktop\Desktop\Perl>perl telnet2.pl
Global symbol "$session" requires explicit package name at telnet2.pl line 24.
Global symbol "$session" requires explicit package name at telnet2.pl line 25.
Execution of telnet2.pl aborted due to compilation errors.
##
##
C:\Users\mydesktop\Desktop\Perl>perl telnet2.pl
"my" variable $session masks earlier declaration in same scope at telnet2.pl line 25.
Useless use of private variable in void context at telnet2.pl line 26.
Use of uninitialized value within %users in string eq at telnet2.pl line 19.
Can't call method "login" on an undefined value at telnet2.pl line 22.
C:\Users\mydesktop\Desktop\Perl>