小编use*_*222的帖子

在expect脚本中处理多个语句

我是期待脚本的新手.

我在linux机器上写了一个ssh的expect脚本,我在不同的linux机器上遇到sshing的问题.我已经复制了脚本.

!/usr/local/bin/expect

set LinuxMachine [lindex $argv 0]

spawn ssh root@$LinuxMachine


expect "root@$LinuxMachine's password:"

send "root123\n"

expect "[root@Client_FC12_172_85 ~]#"

send "ls"

interact
Run Code Online (Sandbox Code Playgroud)

当我10.213.172.85从命令行提供第4行的期望时,它显示为" root@10.213.172.85's password:"并且登录成功

但有些linux会期待 -

The authenticity of host '10.213.172.108 (10.213.172.108)' can't be established.
RSA key fingerprint is da:d0:a0:e1:d8:7a:23:8b:c7:d8:40:8c:b2:b2:9b:95.
Are you sure you want to continue connecting (yes/no)
Run Code Online (Sandbox Code Playgroud)

在这种情况下脚本将无法正常工作.

请告诉我如何在一个expect命令中有两个expect语句.

提前致谢!!!

expect

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

expect ×1