首页 > 代码库 > CentOS 6.5 shell中su切换自动输入密码

CentOS 6.5 shell中su切换自动输入密码

yum -y install expect


login as normal user:

vi su.exp

#!/usr/bin/expect
set timeout 30
spawn su -
expect "Password:"
send "root-pass\r"
interact


chmod +x su.exp

./su.exp

本文出自 “Ilovecat(个人笔记)” 博客,请务必保留此出处http://hj192837.blog.51cto.com/655995/1595972

CentOS 6.5 shell中su切换自动输入密码