except免交互执行命令
###
#!/bin/bash if [ `rpm -qa expect|egrep "expect.*.x86_64"|wc -l` -ne 1 ];then yum install -y expect >/dev/null 2>&1 fi ################################################### #user ~ 想要修改密码的用户 user=(root) #password ~ 想要修改为的密码 password='Dyjt\$1101Ecs' ################################################### expect << EOF spawn bash -c "passwd $user" expect "New password:" send "${password}\r" expect "Retype new password:" send "${password}\r" expect eof; EOF
###