faith丶

导航

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

 

###

posted on 2021-01-25 16:59  faith丶  阅读(148)  评论(0编辑  收藏  举报