我有将我的网络连接到外部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
最佳答案
我将删除-exact
选项:
expect "*SSLVPN down unexpectedly with error:6*" { ...
尝试使用
expect -d
运行,以查看断开连接后为什么模式不匹配。关于linux - 如何使用Linux Expect脚本连接到FortiClient VPN,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32856119/