expect 示例

Posted jkklearn

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了expect 示例相关的知识,希望对你有一定的参考价值。

#!/usr/bin/expect
set timeout 30
set IP [lindex $argv 0]
set USER [lindex $argv 1]
spawn ssh [email protected]$IP
expect {
"Are you sure you want to continue connecting (yes/no)?" {
send "yes "
expect -re "[P|p]assword:" {send "123 "}
}
-re "[P|p]assword:" {send "123 "}
}
expect "~]" {send "touch /tmp/eeee "}
expect "~]" {send "uname -r "}
expect eof

 执行脚本 ./test.sh "192.168.0.105" root















以上是关于expect 示例的主要内容,如果未能解决你的问题,请参考以下文章