Created
April 20, 2016 03:22
-
-
Save armand1m/4146623195ab1a9a7118e8dfa2b92b4d to your computer and use it in GitHub Desktop.
.bash_profile with functions for connecting to vpn using AppleScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function vpn-connect { | |
/usr/bin/env osascript <<-EOF | |
tell application "System Events" | |
tell current location of network preferences | |
set VPN to service "your-vpn-name" | |
if exists VPN then connect VPN | |
repeat while (current configuration of VPN is not connected) | |
delay 1 | |
if exists VPN then connect VPN | |
end repeat | |
end tell | |
end tell | |
EOF | |
} | |
function vpn-disconnect { | |
/usr/bin/env osascript <<-EOF | |
tell application "System Events" | |
tell current location of network preferences | |
set VPN to service "your-vpn-name" | |
if exists VPN then disconnect VPN | |
end tell | |
end tell | |
return | |
EOF | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment