read_parfile (version 1.0)

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

###########################################################################
#
# 
# SYNTAX: read_parfile parfile param
#
# DESCRIPTION: Gets a parameter from a specified parfile
#              note this calls ftool_test to check for errors so
#              the error handling routines should not call this routine
#              to avoid a recursive loop.
#
# VERSION: 1.0
#
# HISTORY: 0.0 -> 1.0 2/6/97
# HISTORY: re-wrote the error checking part to cope with situations
# HISTORY: where the job.par exists but is unreadable without going into an 
# HISTORY: infinite loop.
#
##############################################################################

parfile=$1
param=$2

$FTOOLS/pget ./${parfile} ${param}  >stdout${$}.log 2>stderr${$}.log 
code=$?

if [ $code -ne 0 -o -s stderr${$}.log ]; then
     ##########################
     # there is an error
     ###########################
     
     if [ "$parfile" == "$JOBPAR" ]; then
          #######################################################
          # avoid an infinite loop if the job.par can't be read        
          #######################################################
          echo "ERROR: Can't read $JOBPAR"
          cat stdout${$}.log stderr${$}.log
     else
          ####################################
          # ftool_test can handle the errors  
          ####################################
          $UTIL/ftool_test pget $? $0 1 stdout${$}.log stderr${$}.log
     fi

else
     #############################################################
     # no error, remove initial and final quotes and send the 
     # result to stdout
     ############################################################
     sed -e"s/^\'//g" < stdout${$}.log |sed -e"s/\'\$//g"
fi

######################
# clean up
######################
rm -f stdout${$}.log
rm -f stderr${$}.log


exit 0