Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Perl script for telnet scraping IP addresses looking for Cisco IP Phones
# Marcos Mirabent
# Scan for Cisco IP Phones given a .csv of IP addresses
# Created by Marcos Mirabent on 2013-07-18.
# Copyright 2013 Marcos Mirabent. All rights reserved.
# Use statements
use Net::Telnet ();
use Text::CSV_XS;
# Set up the csv importing
# Set up Telnet
my @phones;
my $csv = Text::CSV_XS->new;
open my $fh, "<", $ARGV[0] or die "cannot open\"".$ARGV[0]."\"!";
# set up telnet object and csv object. Drop the header line in the csv file
$t = new Net::Telnet ();
$csv->bind_columns(\$ip_addr, \$mac_addr);
$csv->getline ($fh);
# iterate through the csv file, extracting the ip address field
while ($csv->getline ($fh)) {
eval {
print "Trying ".$ip_addr."\n";
@lines = $t->cmd('show config');
for $line (@lines) {
if ($line =~ m/Platform.*Phone/) {
print "Found matching IP Phone"."\n";
push @phones,"Phone ".$ip_addr." ".$mac_addr."\n";
}; warn $ip if $@;
for $phone (@phones) {
print $phone;
close $fh;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.