首页 > 其他 > 详细

expect 示例

时间:2019-02-13 22:45:06      阅读:218      评论:0      收藏:0      [点我收藏+]

#!/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 示例

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!