【发布时间】:2015-12-27 15:36:55
【问题描述】:
我有这段代码可以将我的网络连接到外部 vpn,但有时这种连接会丢失。我需要我的代码来检测错误并再次尝试连接。
set force_conservative 0
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
set timeout -1
spawn $env(SHELL)
match_max 100000
proc tryconnection {} {
send -- "./forticlientsslvpn_cli --server SERVER:PORT --vpnuser USER"
expect -exact "./forticlientsslvpn_cli --server SERVER:PORT --vpnuser USER"
send -- "\r"
expect -exact "\r\nPassword for VPN:"
send -- "PASSWORD\r"
expect -exact "\r\nSTATUS::Setting up the tunnel\r\nSTATUS::Connecting...\r"
send -- "Y\r"
expect -exact "\r\nSSLVPN down unexpectedly with error:6\r" {
puts "Send Ctrl+C"
send \003
tryconnection
}
expect eof
}
tryconnection
【问题讨论】:
-
在一个稍微不相关的注释上,你知道是什么导致了错误6吗?我得到了很多,而且似乎重新启动会清除它 - 让我认为它只是上次运行没有清理的一些资源......
标签: linux bash shell expect vpn