#!/usr/bin/expect -f # expect script to automate the use of the passwd program # to set user passwords. To change passwords of other # users, passwd must be run by root. # # Written 12/2009 by Wayne Pollock, Tampa Florida USA # $Id: expect-demo,v 1.0 2009/12/02 08:35:40 wpollock Exp $ set user [lindex $argv 0] set password [lindex $argv 1] if { $user == "" || $password == "" } { puts "Usage: \n" exit 1 } # alt: Have passwd arg only and get the username from the environment: #set user $env(USER) spawn passwd $user expect "password:" send "$password\r" expect "password:" send "$password\r" expect eof