我正在尝试运行脚本以使用期望连接到 Procurve 4204vl 交换机。这是我创建的代码:
#!/usr/bin/expect -f
set timeout 20
spawn ssh -l user 192.168.0.10
expect "user@192.168.0.10's password:"
send "1234"
send "\r"
expect "Press any key to continue"
send "j\r"
send "conf"
send "\r"
send "no ip route 89.19.238.2 255.255.255.255 192.168.0.12"
send "\r"
send "exit"
send "\r"
send "exit"
send "\r"
send "exit"
send "\r"
expect "Do you want to log out [y/n]?"
send "y"
我使用 simple 运行它expect script.exp
,问题是我得到了这些错误:
- 路线没有被删除
脚本执行完成后,屏幕上出现以下错误:
按任意键继续执行无效命令名称“y/n”,同时执行从“期望“您要注销 [y/n]?”(文件“script.exp”第 19 行)中调用的“y/n”
那么,我该如何解决这个问题呢?谢谢你。
PS:如果我评论所有"exit"
行以及注销问题,然后在"interact"
命令的最后一行添加,脚本可以正常工作。