#!/usr/bin/ksh
#
#  Modified for sending messages back to the Palladium supervisor's
#  terminal.
#
#          Alan Hlava
#set -x


        read TO

# First, check if the environment variable identifying the terminal
# is set
DEVICE=`echo $PD_SUV_TERM_DEVICE`
if test -z "$DEVICE" ; then

        # This is the standard code which we use if the
        # environment variable wasn't set correctly

        # Try writing to a tty first.
        write $TO

        # If it fails then just mail it.
        if [ $? != 0 ] ; then
                read FROM
#               mail -s "$FROM" $TO
        fi

else
        # This is the new code where we write back to the
        # supervisor's terminal

        USERID=`echo $USER`

        write $USERID $DEVICE

        # If it fails then just mail it.
        if [ $? != 0 ] ; then
                read FROM
#               mail -s "$FROM" $TO
        fi

fi

#set +x
exit 0
#
#    Version      Date     Time    Owner   Comment
# ------------- -------- -------- -------- ----------------------------
# V             02/28/94 15:34:49 hlava    ainmsg modified for Palladium
