Ok, well here's a sample program that I wrote to change the DST 2007 stuff on all our Cisco devices. It was kind of quick and dirty, but it works, and is short enough that you will catch on to what it does right away. So basically, you have this code in a .pl file:
Code:
use Getopt::Long;
GetOptions(
"host=s" => \$host,
);
use Net::Telnet::Cisco;
$pass='loginpw';
$enable='enablepw';
my $session = Net::Telnet::Cisco->new(Host => $host);
$session->login('login', $pass);
$session->enable($enable);
$session->cmd("configure terminal");
$session->cmd("clock summer-time EDT recurring 2 Sun Mar 2:00 1 Sun Nov 2:00\n");
$session->cmd("end");
my @clock = $session->cmd("show clock\n");
$session->cmd("wr mem\n");
print "@clock\n";
exit;
getopt-long allows you to specify command line options. In this case, I just put the passwords in the actual script, but specified the host I want to run the script against with a -h [hostname] command line option. Like so:
perl.exe tzchange.pl -h switchname
So, what this does is logs into the switch specified by the -h command line option, runs a couple commands:
Code:
$session->login('login', $pass);
$session->enable($enable);
$session->cmd("configure terminal");
$session->cmd("clock summer-time EDT recurring 2 Sun Mar 2:00 1 Sun Nov 2:00\n");
Checks to make sure the time updated, prints the results, and even writes memory (probably a little dangerous without some error checking):
Code:
my @clock = $session->cmd("show clock\n");
$session->cmd("wr mem\n");
And then the script completes. If you wanted to just get a printout of mac-addresses, you would just basically change the commands to perform a "show mac-address-table" (you could also remove the "enable" portion and the "wr mem"), but basically, once you get one script that logs in and successfully executes some commands, there's no limit as to how you can tweak that to do different stuff. You want to check your env, just change the commands to say:
show env all
You can print the output to a file and have it e-mail you. Like I said, the possibilities are basically endless.