To display the connection status of your vpnc connection, use this command line:
pgrep vpnc > /dev/null && echo Connected || echo Disconnected; echo $(ps -p $(pgrep vpnc)
I placed this as a function in my .bashrc files so it is evaluated on every invocation. If this is added as a simple alias, the alias in only evaluated on this creation of the shell and will not get dynamically updated.
vpnc-status() { pgrep vpnc > /dev/null && echo Connected || echo Disconnected; if [ $(pgrep -c vpnc) -gt 0 ] then echo $(ps -p $(pgrep vpnc) -o etime=) fi }
If you add it to your .bashrc file, don’t forget to source the file in order to activate the function:
. ~/.bashrc
Once this function has been activated, invoking it as vpnc-status
will output ‘Connected’ or ‘Disconnected’. If it is connected, it will also display the time it has been running in the [[dd-]hh:]mm:ss
format.