The script distributes files from an AIX server using iether ftp or sftp depending on the constraint of the destination server. I am interested in having the error checking routine critically reviewed. I will only include an excerpt from the script concerning error trapping: (where $FTP_OUT is the log captured for either an "ftp" or an "sfpt" transfer)
Check_for_errors()
{
set -x
RESULT=`egrep -c "not found|No such|refused|failed|error|timed out|not exist|denied|Connection closed|STOR fails|not authorized|timeout|Not connected" $FTP_OUT`
if [[ ! -s $FTP_OUT ]] ; then
error_reporting
ERROR_MSG="** FAILURE **"
echo " No $ftpflag log file produced" >> $TEMP_LOGF
echo " Abandoning transfer. " >> $TEMP_LOGF
elif [[ $RESULT -gt 0 ]] ; then
# The existence of "Transfer Complete" doesn't guarentee a successful result, however it must be present for a successfil result.
# Checking for it's existance excludes the possibility of a null log file or an unknown error type.
error_reporting
ERROR_MSG="** FAILURE **"
else
echo " FTP Success for interface $ftpflag ::: ${ftpfile} " >> $TEMP_LOGF
fi
rm -f $FTP_CMD
rm -f $FTP_OUT
}