Computing.Net > Forums > Unix > Check gz zip files when corruption

Check gz zip files when corruption

Reply to Message Icon

Original Message
Name: hoan0202
Date: November 9, 2007 at 09:21:20 Pacific
Subject: Check gz zip files when corruption
OS: OS
CPU/Ram: 512
Model/Manufacturer: DEL
Comment:

Could some help to check out this script or any syntax red or command out. This script will check any files with (gz, GZ, zip or ZIP) extension if check any file failed then send out the email notify to whoever need it. Thanks

This will run on Autosys:
Command /usr/local/apps/XXX/prod/bin/Checkfiles.ksh WORK_DIR "FILENAME" DC_MAIL


#!/bin/ksh

WORK_DIR=$1
FILENAME=$2
DC_MAIL=$3

DATE=`date +%m%d.%H:%M:%S`
LOGFILE=/usr/local/apps/common/prod/logs/CHECK_${FIELNAME}.${DATE}.log

{

echo "################NEW LOG##############\n"

cd ${WORK_DIR}

ls ${FILENAME}

if (($? > 0));then
echo "ERROR: The gz file was not found!"
exit 10
fi
for DON in `ls $FILENAME`
do

############################################
### GZ, gz, ZIP or zip then check here ###
############################################
####if [[ $TYPE = gz ]] || [[ $TYPE = GZ ]] || [[ $TYPE = zip ]] || [[ $TYPE = ZIP ]] ==> Not sure yet.
#####then

if [[ ${DON} = *.gz ]] || [[ ${DON} = *.zip ]] || [[ ${DON} = *.ZIP ]];then

echo "File has gz extension, moving on..."

else
exit 20

fi

gunzip -t $DON
#unzip -t $DON
if (($? > 0));then
echo "ERROR: Gz file corruption failed! More information should be in this logfile!"
exit 20
fi
done

} >> "${LOGFILE}"

###################################################################
### End of checking it and e-mail to whoever request it.
###################################################################

cat $LOGFILE | mailx -s "Files received was corruption or bad on the server." ${DC_MAIL}

cd /usr/local/apps/common/prod/logs

find *.log -mtime +45 -exec rm -f "{}" \;

exit $?



Report Offensive Message For Removal








Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Check gz zip files when corruption

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge