#! /usr/bin/ksh
#
# Function compJobAttr: run pdls on a single attribute and
# compare its output to our fourth positional parameter.
# If they are equal, return 0 (success) else return 1.
# in this function the parameters are as follows:
#
# Input positional parameters:
#     $1. the class of the object (always JOB)
#     $2. The attribute you are searching for
#     $3. The target i.e. spooler or supervisor name
#     $4. The answer that you expect
#
# This function returns 0 if success, else an error
#
# Author: Tim Unser

# run the pdls command and get its answer
LOC_ANS=`$PD_PATH/pdls -c $1 -r $2 $3 | tail -1 | awk '{ print $2 }'`

# check the return of the pdls
if [ $? != 0 ]
then
	reportError "compJobAttr: pdls failure"
fi

# test to see if pdls returned what we expected - return 0 if yes
if [ "${LOC_ANS}" = "${4}" ]
then
   exit 0
fi

# error - didn't get back what we wanted
reportError compJobAttr: attribute $2 - value got '-->'"${LOC_ANS}"'<--' wanted "${4}"
exit 1
