Skip to content

Instantly share code, notes, and snippets.

@orimanabu
Last active August 29, 2015 14:03
Show Gist options
  • Save orimanabu/ef0f9be640ffbaf467bc to your computer and use it in GitHub Desktop.
Save orimanabu/ef0f9be640ffbaf467bc to your computer and use it in GitHub Desktop.
AppleScript to connect VPN with HOTP
-- references: http://apple.stackexchange.com/questions/78793/apple-script-vpn-textbox
tell application "System Events"
tell current location of network preferences
set VPNservice to service "VPN NAME" -- name of the VPN service
if exists VPNservice then
if current configuration of VPNservice is not connected then
connect VPNservice
else
error "already connected."
end if
end if
end tell
do shell script "/path/to/otp.py | pbcopy"
tell current location of network preferences
delay 1
keystroke "v" using command down
keystroke return
delay 2
keystroke return
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment