gpt4 book ai didi

linux - 如何使用linux Expect脚本连接到forticlient vpn

转载 作者:太空宇宙 更新时间:2023-11-04 03:32:16 24 4
gpt4 key购买 nike

我有这段代码将我的网络连接到外部 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com