【问题标题】:How to use a linux expect script to reconnect to forticlientvpn如何使用 linux expect 脚本重新连接到 forticlient vpn
【发布时间】: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


【解决方案1】:

我会删除 -exact 选项:

expect "*SSLVPN down unexpectedly with error:6*" { ...

尝试使用expect -d 运行,看看为什么在您失去连接时您的模式不匹配。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-11-23
    • 1970-01-01
    • 1970-01-01
    • 2016-07-21
    • 2013-08-15
    • 1970-01-01
    • 2020-10-08
    • 2019-10-14
    相关资源
    最近更新 更多