# tnotify
# ID 6.2 97/08/25
#
# This notify program is run upon completion of an outbound fax job.
# It will display a message on the status line of the user who sent the
# fax request.
#
# This script expects a file to exist in /versyss/data/fax/tmp with
# the file name of the request id (i.e. file name 2015).  This file will
# contain the user number of the user who sent the fax request.
#
# -----------------------------------------------------------------------------
# CHANGE HISTORY SECTION :
#  Rel#    Date                    Description
#  ----- --------   -----------------------------------------------------------
#  5.2.0 09/07/95   Created.
#  6.1.0 08/13/97   Modified to also work with version 3 of VSI*FAX.
#  6.1.0            VSI*FAX Gold Series fax server.
# -----------------------------------------------------------------------------
#
REQID=${1}          # The request id passed by fx

#
# Check version of VSI*FAX
#
if [ -f /etc/vsifax3.sh ]
then
  VSIREL=3
else
  VSIREL=2
fi

#
# Make sure paths are set correctly
#
if [ $VSIREL -eq 2 ]
then
  SET_VSI_ENV=". /etc/vsifax.sh"
else
  SET_VSI_ENV=". /etc/vsifax3.sh"
fi
#
$SET_VIS_ENV
#
# check for a file in the tmp dir with the same name as the request id
#
if [ -f ${VAE}/data/fax/tmp/${REQID} ]
then
#
# get the user number for the user who sent the request
#
  exec < ${VAE}/data/fax/tmp/${REQID}
  read VAE_USER
#
  if [ $VSIREL -eq 2 ]
  then
    eval `flog -e ${REQID}`     # Source variables for the request data
    RESULT=${r_result}
  else
    eval `vfxolog -F eval ${REQID}`
    RESULT=${rrs}
  fi
#
  
#
  if [ $RESULT = "NORMAL" ]
  then
#  echo "Fax request ${REQID} completed successfully." | \
#  wallvae -u$VAE_USER
    rm ${VAE}/data/fax/tmp/${REQID}
  else
    echo "Fax request ${REQID} DID NOT complete, result code = ${RESULT}." | \
    wallvae -u$VAE_USER
    rm ${VAE}/data/fax/tmp/${REQID}
  fi
fi
