Perl Script – Turning Aironet Wireless Interface On/Off

I had a need to be able to quickly turn the wireless interface on/off  on a 1231G Access point.

I wrote this simple Perl Script to logon too the AP via telnet and issue a “No shutdown” on the interface. To Sutdown the interface I use an identical script to perform a “Shutdown”.

You could then have both scripts on your desktop to easily toggle the state of the wireless, or you could do what I do and put the scripts in the start menu and use Launchy to run the scripts.

The Script uses Net::Telnet::Cisco , which can be installed with Perl Package Manager using the following command:

ppm install Net-Telnet-Cisco


APWirelessOn.pl

##
# Filename – APWirelessOn.pl
# Version – 0.1
# Creator – reloadin10
# contact – reloadin10.wordpress.com
# Description – Performs a no shutdown on a specified Cisco AP Interface
##

use Net::Telnet::Cisco;

# Define your variables here
$host=’1.1.1.1′;
$user=’username’;
$pass=’password’;
$enable=”enablePassword”;

#CODE
my $session = Net::Telnet::Cisco->new(Host => $host);
$session->login($user,$pass);
if ($session->enable($enable) ) {
$session->cmd(‘config terminal’);
$session->cmd(‘interface dot11Radio0’);
$session->cmd(‘no shutdown’);
} else {
warn “Can’t enable: ” . $session->errmsg;
}
$session->close;

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s