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
执行该脚本需要用到expect,所有需要安装expect工具(yum -y install expect)
#!/usr/bin/expect
set timeout 2
spawn su
expect "Password:"
exec sleep 1
send "实际的root密码\r"
expect "#"
interact