-
-
Save hfeeki/c7260cd59b1d5f8d20e1 to your computer and use it in GitHub Desktop.
This file contains 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
set msg to "" | |
tell application "System Events" | |
tell current location of network preferences | |
set VPNservice to service "VPN (PPTP)" | |
if exists VPNservice then | |
set isConnected to connected of current configuration of VPNservice | |
if isConnected then | |
disconnect VPNservice | |
set msg to "Disconnected" | |
else | |
connect VPNservice | |
set isConnectedCheck to false | |
#also can try wait util success: repeat until isConnectedCheck | |
#now wait in 20s | |
set x to 0 | |
repeat 10 times | |
set x to (x + 1) | |
set isConnectedCheck to connected of current configuration of VPNservice | |
if isConnectedCheck then | |
set msg to "Connected success in " & (x * 2) & "s " | |
exit repeat | |
else | |
delay 2 | |
end if | |
end repeat | |
if not isConnectedCheck then | |
set msg to "Connect fail in 20s" | |
end if | |
end if | |
end if | |
end tell | |
end tell | |
return text 1 thru -2 of msg |
This file contains 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
#!/bin/sh - | |
osascript $YOURPATH/pptp_autocon.applescript |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment