Start the CISCO VPN client from the command line Posted on 2021-03-24 Edited on 2023-09-14 python gitst https://gist.github.com/alecthegeek/62b340ecb1480326eee1a13252ea83bb 12345678910111213141516171819#!/usr/bin/env expect -f# Start the CISCO VPN client on a Mac. Adapted from# https://blog.felipe-alfaro.com/2014/05/23/automating-cisco-anyconnect-secure-mobility-client-on-mac-os-x/set HOSTNAME vpn.server.comset USER_NAME user.nameset PASSWORD passwordspawn /opt/cisco/anyconnect/bin/vpnexpect { "state: Connected" { send disconnect\n ; exp_continue; sleep 3 } "state: Disconnected" {sleep 2;send "connect $HOSTNAME\n"}}expect -timeout 60 -re "Username: .+] "; send $USER_NAME\nexpect "Password: " ; send $PASSWORD\nexpect "state: Connected"; sleep 2; send exit\n