sort_test (version 0.0)

You can also look at:
#! /usr/bin/ksh

###########################################################################
#
# 
# SYNTAX:  sort_test tool caller level stderr
#          
#          where tool= the name of the STOOL which was just run
#                code= the exit code returned by the STOOL
#                caller= the name of the routine which called the STOOL
#                level=  the level of the error to be generated on failure
#                stdout= the name of a file containing the statdard output from
#                        the STOOL
#                stderr= the name of a file containing the statdard error
#                        output from the STOOL
#
#
#
# DESCRIPTION: This is an error checking routie for gissortcode, gissortsplit, 
# DESCRIPTION: sis0sortcode, sis0sortsplit, sis1sortcode, sis1sortsplit.
# DESCRIPTION: These STOOLS exit with random codes and have routine
# DESCRIPTION: logging output in their stderr output.
# DESCRIPTION: This routine logs the stdoutput and raises an exception
# DESCRIPTION: only if there is an E@ or E# error in stderr. 
#
# VERSION: 0.0
#
# HISTORY:
#
##############################################################################
#DEBUG=1

tool=$1
caller=$2
level=$3
stderr=$4

code=0

if [ -n "$DEBUG" ]; then
     echo ${0##*/} tool=$tool
     echo ${0##*/} caller=$caller
     echo ${0##*/} level=$level
     echo ${0##*/} stderr=$stderr
fi

###########################
# check for serious errors
###########################
errors=$(grep E[123] $stderr |grep -v dropped | wc -l )
if [ $errors -gt 0 ]; then
     ##########################################
     # there are errors so raise an exception
     ##########################################
     $UTIL/exception $caller $level "Error from STOOL $tool"
     code=1
fi

##########################
# log the standard output
##########################
if [ -r "$stderr" ]; then
     outlines=$(wc -l <$stderr)
else
     outlines=0
fi
if [ $outlines -gt 0 ]; then
     ################################
     # there is some standard output
     ################################
     $UTIL/log_entry "Standard Error Output From STOOL ${tool}:"
     $UTIL/file_to_log $stderr

     
fi



rm -f stderr.log

exit