码迷,mamicode.com
首页 > 其他好文 > 详细

expect 示例

时间:2019-02-13 22:32:47      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:name   tin   usr   word   ssh   expect   roo   lin   continue   

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

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

expect 示例

标签:name   tin   usr   word   ssh   expect   roo   lin   continue   

原文地址:https://www.cnblogs.com/jkklearn/p/10372036.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!