#!/usr/bin/expect -f set rootpw [lindex $argv 0] match_max 100000 spawn passwd root expect "New password:" send "$rootpw\r" expect "Retype new password:" send "$rootpw\r" expect eof