#!/bin/bash target=$1 count=$( ping -c 1 10.1.2.3 | grep icmp* | wc -l ) if [ $count -eq 0 ] then echo "VPN is down." echo "password" | sudo openconnect vpn.example.com -u username --passwd-on-stdin --no-cert-check else echo "VPN is UP" fi