Home
Up

Root Password Change

#! /usr/bin/expect
###
# Expect script that will change a password on the command line
#
# eg /usr/local/bin/autopassword root fred123
# changes the root password to fred123
#
# Tested on Linux, prompts may need tuning on other Unix systems
set password [lindex $argv 1]
spawn passwd [lindex $argv 0]
expect "password:"
send "$password\r"
expect "password:"
send "$password\r"
expect eof

© Andrew Marshallsay 2008