1.yum install expect 需要使用这个命令 2.编写 shell脚本 vi test.sh #!/bin/sh echo 'su user[root]!' expect -c " spawn su - root expect \":\" send \"your password\r\" interact " echo "ok!" ~ 3.执行脚本./test.sh

亲测~~有效...~~~
1.yum install expect 需要使用这个命令 2.编写 shell脚本 vi test.sh #!/bin/sh echo 'su user[root]!' expect -c " spawn su - root expect \":\" send \"your password\r\" interact " echo "ok!" ~ 3.执行脚本./test.sh
亲测~~有效...~~~
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。