Hey,
I'm trying to build customized behavior in a bash script for when it is run within an ssh session. This is how I'm finding out if the current session is ssh:
USER=`whoami`
CURRENT_TTY=`ps -Alf | grep $$ | head -n 1 | gawk '{print $13}'`
(! ( ps -Alf | grep "sshd: $USER@$CURRENT_TTY" | grep -v grep )) > /dev/null
IS_SSH_SESSION=$?
I'm wondering if anyone knows of a better way to do this?