Last active
May 22, 2020 07:07
-
-
Save WorldDownTown/375decd0506e39148cb4147294b8bb02 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# setting | |
COMMAND=/opt/cisco/anyconnect/bin/vpn | |
GROUP='' | |
USER='' | |
SERVICE='Cisco AnyConnect' | |
PASS=`security find-generic-password -a "${USER}" -s "${SERVICE}" -w` | |
PASS2='' | |
HOST='' | |
# if not exist then exit | |
if !(type $COMMAND > /dev/null 2>&1); then | |
echo 'Not found cisco' >&2; exit 1 | |
fi | |
# kill Cisco AnyConnect | |
pid=`pgrep 'Cisco AnyConnect Secure Mobility Client'` | |
if [ -n "${pid}" ]; then | |
echo "Can I kill 'Cisco AnyConnect'? [Enter] "; ps aux $pid; read | |
kill $pid | |
fi | |
# connect | |
printf "${GROUP}\n${USER}\n${PASS}\n${PASS2}" | $COMMAND -s connect $HOST | grep "state: Connected" | |
if [ $? = 0 ]; then | |
~/say.sh "connected" | |
else | |
~/say.sh "Login failed" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment