Skip to content

Instantly share code, notes, and snippets.

@WorldDownTown
Last active May 22, 2020 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WorldDownTown/375decd0506e39148cb4147294b8bb02 to your computer and use it in GitHub Desktop.
Save WorldDownTown/375decd0506e39148cb4147294b8bb02 to your computer and use it in GitHub Desktop.
#!/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