#!/bin/sh
# usage: chpw < file.containing.list.of.routers currentpw newpw vtypw newvtypw
#
# Any commands which may be typed at the console of the router may be placed in
# this script.  Typical uses are to change the passwords on a set of routers, 
# to change snmp community names, to gather the version information 
# for an upgrade # (show cont mci, show cont cbus, show cont tok, show hard).
#
# The list of routers should be contained in a file, one router to a line, or it
# may be typed in from the command line (end list with ctrl-d).
#
while read TEMP
do 
{
#	send vty login password
	echo $3
#	set terminal length to 0 (no hold)
        echo term len 0
#	display interface information
        echo show interface
#	enter privileged command mode
	echo enable
	echo $1
#	enter configuration mode
	echo conf t
#	change the enable password
	echo enable-password $2
#	change the vty password
	echo line vty 0 4
	password $4
#	exit configuration mode
	echo ^Z
#	I use another script to make the changes permanent, after checking a few
#	routers to make certain they are good.  You could put the wr mem command
#	here, however.
#	write mem
#	logoff router
        echo quit
#	wait for completion of script
        sleep 30
} | telnet $TEMP
done

