1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
#! /usr/bin/perl
use Net::Telnet::Cisco;
use strict;
#read host ip from command line
my $host = $ARGV[0];
my $username = $ARGV[1];
my $password = $ARGV[2];
my $enable_password = $ARGV[3];
#connection to the host
my $session = Net::Telnet::Cisco->new(Host => $host);
$session->login($username,$password);
#execute command on the host and keep result
my @output="";
if($session->enable($enable_password)){
@output = $session->cmd('show version');
}
$session->close;
print @output; |
Partager