shell-linux普通用户自动登录root脚本

执行该脚本需要用到expect,所有需要安装expect工具(yum -y install expect)

#!/usr/bin/expect

set timeout 2

spawn su

expect "Password:"

exec sleep 1

send "实际的root密码\r"

expect "#"

interact

 

posted @ 2018-05-23 16:37  奔跑在study的路上  阅读(3315)  评论(1编辑  收藏  举报