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

FortiClient macOS "on_connect" script executes before connection is established

I wanted to use the on_connect script in the FortiClient to connect an smb share after the connection is established as shown here. But the command is executed before the connection is established. After my command failed the connection is shown as established in FortiClient. I tried to execute the command in the background but failed to do so.

 

                    <on_connect>
                        <script>
                            <os>mac</os>
                            <script>
                                echo "" &amp; sleep 4; /usr/bin/osascript -e 'mount volume "smb://ssldemo.fortinet.com/installers"'
                            </script>
                        </script>
                    </on_connect>

 

 

Environment:
MacOS 14.6.1
FortiClient 7.4.0.1645
SSL-VPN via SAML SSO using the external browser as user-agent

1 Solution
Anil_Solakoglu

Hi, 

I have done research based on the reported behavior and observed the following. 

1024936 FortiClient cannot sync VPN on connect script properly.

 

https://docs.fortinet.com/document/forticlient/7.4.0/macos-release-notes/124818/known-issues
This is addressed to fix at 7.2.5 which is released today. 

Please check the persistence of the issue with the specified build and if there are still issues raise a support ticket to troubleshoot further. 

View solution in original post

10 REPLIES 10
rymonds44
New Contributor

The issue arises because the on_connect script in FortiClient runs before the VPN connection is fully established, causing your SMB share command to fail. To address this, you can use a small script that introduces a delay or continuously checks for the connection to be active before executing your SMB command. Here's an example using a loop in PowerShell

 

 If you are downloading a rage game on PC

This script waits for the server to respond before mapping the SMB share. Replace placeholders with your server and credentials, and set this script as your on connect command. This ensures the command runs only after the VPN connection is fully established.

 
 
Announcements
Check out our Community Chatter Blog! Click here to get involved
Labels
Top Kudoed Authors