Linux Shell自动交互(expect)
su root
yum install -y expect
---------------------------
vi test.sh
----------------------------------
#!/usr/bin/expect
spawn su root
expect "password: "
send "123456\r"
expect eof
exit
---------------------------
chmod 775 test.sh
-------------------------
在其它脚本里调用
#!/bin/sh
. ./binshscript.sh
#expect script
./test.sh