use Net::Telnet::Cisco;

  my $session = Net::Telnet::Cisco->new(Host => '192.168.166.109');
  $session->login('', '123');

  # Execute a command
  my @output = $session->cmd('show version');
  print @output;

  # Enable mode
  if ($session->enable("123") ) {
      @output = $session->cmd('show run');
      print "My privileges: @output\n";
  } else {
      warn "Can't enable: " . $session->errmsg;
  }

  $session->close;

#cisco设备IP:192.168.166.109
#telnet 密码为123
#enable 密码为123
#login项为空
 
_____________________________________
#修改密码
 
use Net::Telnet::Cisco;
my @ip=qw/192.168.166.109/;
my ($username,$passwd,$en_passwd,$new_passwd,$new_en_passwd,$log)=("","123","123","switch2008","cisco2008","input.txt");
for my $host(@ip)
{
  my $session = Net::Telnet::Cisco->new (Host => $host,Input_log=>"$log");
  $session->login($username,$passwd);
    if ($session->enable($en_passwd))
    {
       $session->cmd('config terminal');
       $session->cmd('line vty 0 4');
       $session->cmd('login');
       $session->cmd("password $new_passwd"); #modify $passwd
       $session->cmd("enable secret $new_en_passwd");
       $session->cmd('exit');
     }
     else
    {
     warn "Can't enable: " . $session->errmsg;
    }
  $session->close;
}
09-13 19:25