##/bin/bash
password=‘Aa123456‘
for user in $(cat ./user_id)
do
/usr/bin/expect <<Eof
set timeout 10
expect "*#"
spawn /usr/sbin/useradd ${user}
expect "*#"
spawn /usr/bin/passwd ${user}
expect {
"*password:" { send "$password\r"; exp_continue}
"*password:" { send "$password\r"}
}
Eof
done
本文出自 “流星宇” 博客,谢绝转载!
原文地址:http://8789878.blog.51cto.com/8779878/1770871