如何在OS X下获取当前连接的VPN名称

时间:2012-05-01 14:58:00

标签: macos bash vpn

我知道我可以通过

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

但有没有办法获取当前正在使用的VPN名称?

1 个答案:

答案 0 :(得分:5)

假设您指的是使用网络偏好设置注册的VPN服务,AppleScript,特别是系统事件'网络偏好设置套件将起作用:

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

如果您需要从shell访问此内容,osascript -e是您的朋友(每行AppleScript一个-e选项,请注意引用和转义 - 请参阅man osascript)。