Linux Shell自动交互(expect)

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

猜你喜欢

转载自crabdave.iteye.com/blog/2317285