#!/usr/bin/perl -w # setpassCat.pl # February 26-27, 2001 use strict; use Net::Telnet::Cisco; use vars qw($before $match); my $target = ''; my $oldpass = ''; my $olden = ''; my $newpass = ''; umask oct 177; my $cs = Net::Telnet::Cisco->new( host=>"$target", errmode=>'return', timeout=>'30', input_log=>'ciscoconf.log',) or die " Error connecting to $target\n"; $cs->login('',$oldpass) or die " Error logging in to $target. Bad password?\n"; print " ", $cs -> last_prompt, "\n"; &PAUSE(); $cs->enable($olden) or die " Error getting $target privilaged mode.\n"; print " ", $cs -> last_prompt, "\n"; &PAUSE(); my $telnet = $cs -> print('set pass') or die "Error giving \"set pass\" command.\n"; ($before,$match) = $telnet -> waitfor('Enter old password:') or die "Error getting \"Enter old password\" prompt\n"; print " ", $cs -> last_prompt, "\n"; &PAUSE(); my $output = $cs -> print("$oldpass") or die "Error giving existing access password.\n"; ($before,$match) = $telnet -> waitfor('Enter new password:') or die "Error getting \"Enter new password\" prompt\n"; print " ", $cs -> last_prompt, "\n"; &PAUSE(); $output = $cs -> print("$newpass") or die "Error giving new access password.\n"; ($before,$match) = $telnet -> waitfor('Retype new password:') or die "Error getting \"Retype new password\" prompt\n"; print " ", $cs -> last_prompt, "\n"; &PAUSE(); $output = $cs -> print("$newpass") or die "Error confirming new access password.\n"; ($before,$match) = $telnet -> waitfor('Password changed') or die "Error getting \"Password changed\" confirmation.\n"; print " ", $cs -> last_prompt, "\n"; $cs->close; ######################################################################### sub PAUSE { print " to continue...\n"; my $continue = ; } #########################################################################