执行该脚本需要用到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
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。