#! /usr/bin/ksh
#
# Function compAnAttr: 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
#     $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
#
# 12/18/93 JRB Added support for values with spaces and null values

typeset bn=$(basename $0)

typeset PARM_ANS="$4"

#printf "%-16s[%3d]: PARM_ANS = \"$PARM_ANS\"\n" $bn $LINENO

typeset ATTR="$2"

# run the pdls command and get its answer
LOC_ANS=`$PD_PATH/pdls -c $1 -r $2 $3 | sed 's/^.* = //'`

# check the return of the pdls
[ $? != 0 ] && printf "%-16s[%3d]: pdls failure\n" $bn $LINENO

# test to see if pdls returned what we expected - return 0 if yes
# the value from the command line allowing pattern matching.
case "${LOC_ANS}" in
	${PARM_ANS})
		# success - pdls result matched test pattern
		exit 0;;
	*)	# error - didn't get back what we wanted
		printf "%-16s[%3d]: ---------- ERROR ----------
	>>> pdls did not return expected value <<<
	attribute: $ATTR
	expected:  >${PARM_ANS}<
	got:       >${LOC_ANS}<\n" $bn $LINENO;
		exit 1;;
esac



