How to get the name of a connected VPN connection under OS X

I know that I can get the Wifi SSID by doing

/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | sed -e "s/^  *SSID: //p" -e d

but is there a way to get the VPN name that is currently in use?

+3
source share
1 answer

Assuming that you are referring to the VPN service registered in the network settings, AppleScript, in particular System Network Network Preferences Suite, will work:

tell application "System Events"
    tell current location of network preferences
        get name of every service whose (kind is greater than 11 and kind is less than 16) and connected of current configuration is true
    end tell
end tell

If you need to access this from the shell, osascript -eyour friend (one -eoption in the AppleScript line, pay attention to the quote and escaping - see man osascript).

+5
source

All Articles