Listing 1: check_ftp.sh
# get the sum of the LOCAL file
`sum -r ${FILENAME} | cut -d" " -f1 \
> ${TMP_FILE}.$$.1`
# get the sum of the REMOTE file
remsh ${TO_NODE} -l ${TO_ID} -n sum \
-r ${FILENAME} | cut -d" " -f1 \
> ${TMP_FILE}.$$.2
# check if the two "sums" match
CHECK=`diff ${TMP_FILE}.$$.1 \
${TMP_FILE}.$$.2 | wc -l`
if [ ${CHECK} -ne 0 ] # IF the sums don't match THEN
then # remove the local and remote file
remsh ${TO_NODE} -l \
${TO_ID} -n rm -f \
${FILENAME}
rm -f ${FILENAME}
else # ELSE the file was FTP'd OK so
rm -f ${FILENAME} # cleanup the local file
fi # end of if sums don't match
# End of File
|