首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在自动化过程中无法在Expect Shell脚本中建立主机的真实性时,如何忽略或传递“是”

在自动化过程中无法在Expect Shell脚本中建立主机的真实性时,如何忽略或传递“是”
EN

Stack Overflow用户
提问于 2015-02-11 18:29:06
回答 2查看 33K关注 0票数 23

当以下语句在执行Expect Shell脚本时出现时,我希望自动提供“是”,或者忽略它,并以安全的方式进行操作。

代码语言:javascript
复制
#!/usr/bin/expect
spawn ssh $user@$host

不能确定宿主abcdef(10.566.1.98)的真实性。RSA密钥指纹是jk:94:ba:93:0b:eb:ff:df:ea:gh:hj:23:3c:hj:9c:be.您确定要继续连接(是/否)吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-02-12 04:54:15

在这个场景中使用exp_continue

代码语言:javascript
复制
#!/usr/bin/expect 
set prompt "#|>|\\\$"
spawn ssh dinesh@myhost
expect {
        #If 'expect' sees '(yes/no )', then it will send 'yes'
        #and continue the 'expect' loop
        "(yes/no)" { send "yes\r";exp_continue}
        #If 'password' seen first, then proceed as such.
        "password"
}
send "root\r"
expect -re $prompt

参考资料:期望

票数 5
EN

Stack Overflow用户

发布于 2019-08-21 12:18:01

这是可行的,而且对于码头建造来说特别方便

代码语言:javascript
复制
ssh-keyscan hostname.example.com >> $HOME/.ssh/known_hosts
票数 11
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28461713

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档