bash - How to use a linux expect script to reconnect to forticlientvpn -
i have code connects network external vpn, connection lost. need code detect error , try connect again.
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 vpn:" send -- "password\r" expect -exact "\r\nstatus::setting tunnel\r\nstatus::connecting...\r" send -- "y\r" expect -exact "\r\nsslvpn down unexpectedly error:6\r" { puts "send ctrl+c" send \003 tryconnection } expect eof } tryconnection
i remove -exact
option:
expect "*sslvpn down unexpectedly error:6*" { ...
try running expect -d
see why pattern not matching when lose connection.
Comments
Post a Comment