fetch_file (version 0.0)

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

###########################################################################
#
# 
# SYNTAX: fetch_file dir file
#
# DESCRIPTION: copies the specified file from the specified directory
#              to the current directory.
#              It checks if the file exists in the current directory 
#              and in the source directory.
#
# VERSION: 0.0
#
# HISTORY:
#
##############################################################################

dir=$1
file=$2

#############################################
# check that file and directory are defined
#############################################
if [ -z "$dir" ]; then
     $UTIL/exception $0 1 "source directory undefined"
     exit 1
fi

if [ -z "$file" ]; then
     $UTIL/exception $0 1 "file undefined"
     exit 1
fi



if [ ! -a "$file" ]; then
     ################################################
     # file does not exist yet in current directory
     ################################################
     $UTIL/log_entry "Fetching ${file}"

     cp ${dir}/${file} .
     $UTIL/exit_test $? $0 1 "while fetching ${file} from ${dir}"

else
     #########################
     # file already exists
     #########################
     $UTIL/log_entry "$file already present in current directory"
fi



exit 0