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 示例的主要内容,如果未能解决你的问题,请参考以下文章
shell——随机数(RANDOM)+ expect 自动应答
FastJson处理数据出现错误 com.alibaba.fastjson.JSONException: syntax error, expect {, actual error, pos 1(示例代
webpack 打包压缩 ES6文件报错UglifyJs + Unexpected token punc «(», expected punc «:»(示例代码