#######################################################################
#
# waitForJobComplete
#
# Description:
#       Wait for a job to complete printing before returning.
#       A timeout (seconds) must be specified.  If it doesn't complete
#       printing within the timeout period, we exit with code 1.
#       Otherwise, we exit with code 0.
#
# Author:
#       Alan Hlava
#
#######################################################################
#set -x

if [ $# -ne 2 ]
then
        echo "usage: $0 {<local-jobID> | <global-jobID> | <server>:} <timeout>"
        exit 1
fi

SLEEP=10
TIME=$2

while [ `$PD_PATH/pdls -c job $1 2>/dev/null | wc -c` -ne 0 ]
do
   sleep $SLEEP
   TIME=`expr $TIME - $SLEEP`
   if [ $TIME -le 0 ]
   then
        exit 1
   fi
done

exit 0
#
#    Version      Date     Time    Owner   Comment
# ------------- -------- -------- -------- ----------------------------
# V             04/15/94 07:47:00 hlava    Original version
# V1.2          04/15/94 12:56:53 hlava    BL 6 version
# V1.3          06/28/94 14:24:04 nrjbehrs return if bad job id
# V1.4          06/28/94 14:35:52 nrjbehrs support for globals
