Support Forum
The Forums are a place to find answers on a range of Fortinet products from peers and product experts.
ldrahnik
New Contributor II

Problem during connecting with disconnecting last connection when is allowed only 1 at time via cli

Hello,

 

I connect to the VPN with the command below usually and it works fine but when I am disconnected because for example connection problems and the last connection persisted on the server and server allows have only one connection at time I am not able to use the same way how to connect. Why? Because displayed popup:

 

You already have an open SSL VPN connection. Opening multiple connections is not permitted. Do you want to proceed and disconnect your other connection?

 

is displayed for like second and immediately is hidden. Command log:

 

```

$ /opt/forticlient/forticlient-cli vpn connect MyVPNName

Connect VPN: MyVPNName
Status: Connecting...
=====================
Authentication Required
---------------------
An email message containing a Token Code will be sent to <luxxx.xxxxxxx@xxxxxxx.cz> in a moment.
=====================
FortiToken:

=====================
Confirmation Required
---------------------
You already have an open SSL VPN connection. Opening multiple connections is not permitted. Do you want to proceed and disconnect your other connection?
=====================
Confirm (y/n) [default=n]:Confirm (y/n) [default=n]:Status: Disconnected
Notification: Login canceled

DONE.

```

 

I tried to add `--auto-connect` but it was not helpful. Anyway I can confirm using GUI it works, I mean when I answer to (not missing) popup yes and confirm disconnecting the previous connection.

 

```

$ forticlient version

FortiClient Version: 7.2.2.0753
FortiClient Serial: FCT8001727034123
FortiClient UID: EE266A9AE5004693ABCEFDE24314F858

=====================================
Engines
=====================================
AntiVirus: 6.00287
Vulnerability: 2.00031

=====================================
Signatures
=====================================
AntiVirus: 1.00000
AntiVirus Extended: Unavailable
Vulnerability: 1.00034
Sandbox: Unavailable
ICDB: 1.00026

```

1 Solution
ldrahnik
New Contributor II

 

Because it looks like it asks twice:

 

```

Confirm (y/n) [default=n]:Confirm (y/n) [default=n]:

```

 

I tried it solve using `expect`:

 

```

#!/usr/bin/expect
 
set USER [lindex $argv 0]
set PASS [lindex $argv 1]
 
spawn /opt/forticlient/fortivpn connect MyVPNName --user=$USER --password
expect {
    "Password:*" { 
set timeout 1
send -- "$PASS\r"
expect eof
    }
}
```
 

And it works. How I understand why `expect` works: `expect` uses `spawn` which creates a process in the background and with `set timeout 1` then after autocompleting the password is process left in the background and because of that is not cancelled GUI popup question.

View solution in original post

1 REPLY 1
ldrahnik
New Contributor II

 

Because it looks like it asks twice:

 

```

Confirm (y/n) [default=n]:Confirm (y/n) [default=n]:

```

 

I tried it solve using `expect`:

 

```

#!/usr/bin/expect
 
set USER [lindex $argv 0]
set PASS [lindex $argv 1]
 
spawn /opt/forticlient/fortivpn connect MyVPNName --user=$USER --password
expect {
    "Password:*" { 
set timeout 1
send -- "$PASS\r"
expect eof
    }
}
```
 

And it works. How I understand why `expect` works: `expect` uses `spawn` which creates a process in the background and with `set timeout 1` then after autocompleting the password is process left in the background and because of that is not cancelled GUI popup question.

Announcements

Select Forum Responses to become Knowledge Articles!

Select the “Nominate to Knowledge Base” button to recommend a forum post to become a knowledge article.

Labels
Top Kudoed Authors