brock
1/3/2013 - 7:24 PM

A function to start the OSX VPN from the command line. Just modify "My VPN Name" to the name you have in Network Preferences. Then from the

A function to start the OSX VPN from the command line. Just modify "My VPN Name" to the name you have in Network Preferences. Then from the command line run: vpn.

# place this with other bash functions in either ~/.bash_profile or a similar location

vpn () {
  /usr/bin/env osascript <<EOF
tell application "System Events"
        tell current location of network preferences
                set VPN to service "My VPN Name"
                if exists VPN then connect VPN
        end tell
end tell
EOF
}