Skip to content

Instantly share code, notes, and snippets.

@a-morales
Created November 6, 2015 20:15
Show Gist options
  • Save a-morales/3f6bde90eb1cc286f6f2 to your computer and use it in GitHub Desktop.
Save a-morales/3f6bde90eb1cc286f6f2 to your computer and use it in GitHub Desktop.
connect to VPN
#!/usr/bin/env bash
# change FOO to whatever the VPN connection name is called
# set FOO_VPN_PASS as the password to automatically connect
# for manual connection delete lines 10-12
/usr/bin/env osascript <<-EOF
tell application "System Events"
set status to do shell script "scutil --nc status FOO"
if status does not start with "Connected" then
do shell script "scutil --nc start FOO"
delay 2
keystroke (system attribute "FOO_VPN_PASS")
keystroke return
else
log "Already Connected"
end if
end tell
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment