我知道我可以通过这样做来获取 Wifi SSID
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | sed -e "s/^ *SSID: //p" -e d
但是有没有办法获取当前正在使用的 VPN 名称?
假设您的意思是使用 Network Preferences 注册的 VPN 服务,AppleScript,特别是System Events的Network Preferences Suite将起作用:
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
是您的朋友(-e
AppleScript 每行一个选项,请注意引用和转义 - 请参阅man osascript
)。