Tuesday

Cisco VPN Client Shell Script on OS X

I like to start and stop the VPN client from the command line, but sometimes, for whatever reason, the VPN service isn't running or isn't responding. I then have to go Google it to find the incantation to restart it. Rather than do that every time, I use this script to connect to the VPN:

CMD="sudo vpnclient connect MyProfileName user myUserName pwd myPassword"
yes | $CMD
if [[ $? -eq 8 ]]
then
# exit code of 8 means it couldn't connect to the vpnd
sudo /System/Library/StartupItems/CiscoVPN/CiscoVPN restart
yes | $CMD
fi

No comments: