#!/usr/bin/expect | |
# | |
# Set Password for a specific new user | |
# This script should be run as 'root' | |
# | |
# Example: | |
# ./set_passwd USER PASSWD | |
# | |
if { [llength $argv] < 2} { | |
exit 1 | |
} | |
set USER [lindex $argv 0] | |
set PASSWD [lindex $argv 1] | |
set timeout 30 | |
spawn passwd $USER | |
expect "Enter new password: " | |
sleep 1 | |
exp_send "$PASSWD\r" | |
expect "Re-type new password: " | |
sleep 1 | |
exp_send "$PASSWD\r" | |
expect success | |
exit 0 |