expect问题求教
发表于 : 2010-01-06 17:23
我是菜鸟
已经试验成功的脚本
#!expect
set remotehost [lindex $argv 0]
spawn ssh $remotehost
expect "*password:*"
send "xxxxx\n"
interact
exit
#ssh.exp
然后在另一个shell里调用
#!sh
eval "./ssh.exp xxx.xxx.xxx.xxx"
现在遇到这样一个问题,如果初次连接一台主机会提问:
The authenticity of host '10.204.176.25 (10.204.176.25)' can't be established.
RSA key fingerprint is 7a:76:b4:b2:e2:a8:50:44:03:d7:1a:1c:1a:9d:78:46.
Are you sure you want to continue connecting (yes/no)?
所以我改动了一下ssh.exp
expect "*password:*" {send "111111\n"} "*yes/no*" {send "yes\n"}
interact;
exit;
但是这样一旦出现提问yes/no,确实可以回答yes,但后面出现的密码就无能为力了
请教大家该怎么改?谢谢!

已经试验成功的脚本
#!expect
set remotehost [lindex $argv 0]
spawn ssh $remotehost
expect "*password:*"
send "xxxxx\n"
interact
exit
#ssh.exp
然后在另一个shell里调用
#!sh
eval "./ssh.exp xxx.xxx.xxx.xxx"
现在遇到这样一个问题,如果初次连接一台主机会提问:
The authenticity of host '10.204.176.25 (10.204.176.25)' can't be established.
RSA key fingerprint is 7a:76:b4:b2:e2:a8:50:44:03:d7:1a:1c:1a:9d:78:46.
Are you sure you want to continue connecting (yes/no)?
所以我改动了一下ssh.exp
expect "*password:*" {send "111111\n"} "*yes/no*" {send "yes\n"}
interact;
exit;
但是这样一旦出现提问yes/no,确实可以回答yes,但后面出现的密码就无能为力了
请教大家该怎么改?谢谢!