#!/bin/bash mydir=$(dirname "$0") sudo "$mydir/send_login_alert.sh" shell=$(getent passwd $LOGNAME | cut -d: -f7) if [[ -n $SSH_ORIGINAL_COMMAND ]] # command given, so run it then exec "$shell" -c "$SSH_ORIGINAL_COMMAND" else # no command, so interactive login shell exec "$shell" -il fi