#!/usr/bin/expect -- # wrapper to make passwd be noninteractive # username is passed as 1st arg, passwd as 2nd # Executable only by root spawn passwd [lindex $argv 0] set pass [lindex $argv 1] expect "Enter new UNIX password:" sleep 1 send "$pass\r" expect "Retype new UNIX password:" sleep 1 send "$pass\r" expect eof #end script