Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vwrs/f99128fb3c64bc06d2ee908d7bed1a0d to your computer and use it in GitHub Desktop.
Save vwrs/f99128fb3c64bc06d2ee908d7bed1a0d to your computer and use it in GitHub Desktop.
macos-push-connect-button-for-cisco-secure-client
#!/bin/bash
VPN_CMD="/opt/cisco/secureclient/bin/vpn"
PROFILE_NAME="your_profile"
if $VPN_CMD state | grep -q "state: Connected" ; then
$VPN_CMD disconnect "$PROFILE_NAME"
killall "Cisco Secure Client" 2>/dev/null
exit 0
fi
open /Applications/Cisco/Cisco\ Secure\ Client.app
osascript <<EOF
tell application "System Events"
tell application process "Cisco Secure Client"
repeat until exists window 2
delay 0.1
end repeat
try
click button "Connect" of window 2
on error
set btnList to name of every button of window 2
display dialog btnList
end try
end tell
end tell
EOF
# for debug
# ---
# osascript <<EOF
# tell application "System Events"
# tell application process "Cisco Secure Client"
# set treeDump to ""
# set windowCount to count of windows
# set treeDump to "Window Count: " & windowCount & linefeed
# repeat with w from 1 to windowCount
# set treeDump to treeDump & "Window " & w & ": " & name of window w & linefeed
# set UIelements to entire contents of window w
# repeat with el in UIelements
# try
# set treeDump to treeDump & "Name: " & name of el & "Role: " & role of el & "Class: " & class of el & linefeed
# end try
# end repeat
# end repeat
# display dialog treeDump
# end tell
# end tell
# EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment