expect
#!/bin/sh
if [ $# != 2 ];then
echo "usage: $0 username password"
exit 1
fi
username=$1
password=$2
/usr/bin/expect <<EOF
send_user "execute:$0\n"
set timeout 60
spawn passwd $username
expect "New password"
send "$password\n"
expect "Retype new password"
send "$password\n"
expect {
timeout {exit 1 }
eof {exit 0}
}
EOF
不乱于心

浙公网安备 33010602011771号