#!/usr/bin/expect -f set user [lindex $argv 0] set newpwd [lindex $argv 1] set timeout 10 spawn passwd $user expect "*password:" {send "$newpwd "} expect "*password:" {send "$newpwd "} expect eof exit