use warnings; use strict; use Net::Telnet::Cisco; my $session = Net::Telnet::Cisco->new(Host => 'xxx.xx.xx.xx); $session->login('','password'); # no paging - disrupts output $session->cmd('terminal length 0'); my @output1 = $session->cmd('show int status | include connected'); my @connected; my @port; my @macs; # get only connected ports foreach (@output1) { # should be splitting on those that are connected my @tmp = split(/ /, $_); # just get a stream of interfaces? push @port, $tmp[0]; # create new command my $string; $string = "sh mac-address-table int $tmp[0]" if defined $tmp[0]; # show what we get push @macs, $session->cmd($string); } # go through sh mac-address-table for connected interfaces # get just mac address my $cmd; my @ip; foreach (@macs) { if(m/(\.\w{4}\.\w{4})/) { $cmd = "sh ip arp | include $1"; push @ip, $session->cmd($cmd); } } #extract ip and perform nslookup foreach (@ip) { if(m/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/) { print `nslookup $1`; } } $session->close;