#! /usr/bin/ksh 
#
# Function compMvAttr: run pdls on a single multi-valued attribute and
# compares its output to the fourth positional parameter (a record).
# If they are equal, return 0 (success) else return 1.  This function is
# a minor modification to compAnAttr, 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: Giovanni Perrone

# run the pdls command and get its answer

# the sed -e 's/[^=]*=[[:space:]]*\([^[:space:]]*\)/\1 /g'
# should be able to take care of the multi-entries in
# one line, such as 'a = b a = c a = d'

LOC_ANS=`$PD_PATH/pdls -s line -c $1 -g -r $2 $3 \
         | sed -e 's/[^=]*=[[:space:]]*\([^[:space:]]*\)/\1 /g' \
         | sed -e 's/^.*=//' -e 's/^[ ]*//' \
         | awk '{ for(i=1; i<=NF; i++ ) { print $i}}' \
         | buildMvAttr`

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

# test to see if pdls returned what we expected - return 0 if yes
case "${LOC_ANS}" in
	${4}) exit 0;;
esac

# error - didn't get back what we wanted
reportError compMvAttr: attribute $2 - value got '-->'"${LOC_ANS}"'<--' wanted "${4}"
exit 1
#
#    Version      Date     Time    Owner   Comment
# ------------- -------- -------- -------- ----------------------------
# V1.2          11/17/94 17:48:13 nrjbehrs iut -g fix; media object validation
