DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Perl - Cisco Wireless Managment

  • submit to reddit
        // Perl script to update MAC access table on Cisco IOS-based AiroNets


# Update Aironet IOS mac addresses

use Net::Telnet::Cisco;
use vars qw($r @data);

print "Content-type:text/html\n\n";

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
    ($name, $value) = split(/=/, $pair);
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $FORM{$name} = $value;

$macaddr = $FORM{'command'};
#$macaddr = 'AABBCCDDEEFF';

print "using command <u>username <b>$macaddr</b> password <b>0$macaddr</b></u><br><br>";

print "Updating AP <b> (conference center)</b>    <br>";
$r = Net::Telnet::Cisco->new(Host=>"");
die($r->errmsg) unless($r->enable("password"));
	$r->cmd('terminal length 0');
	$r->cmd('config t');
	$r->cmd("username $macaddr password $macaddr");
	$r->cmd("username $macaddr autocommand exit");
	$r->cmd("write memory quiet");
	$r->cmd('terminal length 24');
print "Done!";