Skip to content

Instantly share code, notes, and snippets.

@rolindroy
Created December 8, 2017 09:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rolindroy/7049daacce3f8fbd50d7a904f9aa49c1 to your computer and use it in GitHub Desktop.
Save rolindroy/7049daacce3f8fbd50d7a904f9aa49c1 to your computer and use it in GitHub Desktop.
-- Apple Script to connect VPN Client with Password and Safenet MobilePass OTP.
set vpn_name to "'VPN Connection 01'"
set user_name to "username"
set passwd to "Password"
tell application "MobilePASS"
activate
end tell
tell application "System Events"
tell table 1 of scroll area 1 of window "MobilePASS" of application process "MobilePASS"
select row 1
end tell
click button "Copy Passcode" of window "MobilePASS" of application process "MobilePASS"
end tell
tell application "System Events"
set rc to do shell script "scutil --nc status " & vpn_name
if rc starts with "Connected" then
do shell script "scutil --nc stop " & vpn_name
else
set otp to the clipboard
do shell script "scutil --nc start " & vpn_name & " --user " & user_name
delay 1
keystroke passwd
keystroke otp
keystroke return
end if
end tell
tell application "MobilePASS"
quit
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment