#!/usr/bin/expect
set PORT 2222
set HOST 13.214.147.196
set USER root
set PASSWORD DT8ajY0lFudf6D9Y
spawn ssh -p $PORT $USER@$HOST
expect {
"yes/no" {send "yes\r";exp_continue;}
"*password:*" {send "$PASSWORD\r"}
}
interact
将以上文件保存为 test_client
打开items,将文件位置填到command,前面加上expect+空格
expect脚本解读:
下载安装:
$ apt-get install expect
$ yum install expect
spawn | Starts a script or a program. |
---|---|
expect | Waits for program output. |
send | Sends a reply to your program. |
interact | Allows you to interact with your program. |
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。