applescript:vpn
AppleScriptでVPN接続を切り替え
コマンドラインでvpn接続を切り替える
tell application "System Events" tell current location of network preferences set vpn to the service "サービス名" if current configuration of vpn is not connected then connect vpn else disconnect vpn end if end tell end tell
サービス名
にはシステム環境設定のネットワークで作成したVPNのサービス名を正確に入れる(空白に注意)
これを適当な名前で保存し、以下のコマンドでvpn切り替えができる
osascript path/to/this/applescript/file
bashrcなどに以下の記述をしておくと良いだろう
alias vpn="osascript path/to/this/applescript/file"
applescript/vpn.txt · 最終更新: 2022/03/10 03:46 by nullpon