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

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Check gz zip files when corruption

Reply to Message Icon

Name: hoan0202
Date: November 9, 2007 at 09:21:20 Pacific
OS: OS
CPU/Ram: 512
Product: 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 $?




Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


read line bye line withou... Perl one-liner parsing



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Check gz zip files when corruption

extract zip file(HPUX) www.computing.net/answers/unix/extract-zip-filehpux/6036.html

Checking multiple .htpasswd files www.computing.net/answers/unix/checking-multiple-htpasswd-files/3652.html

Check for new file, exec sql*plus www.computing.net/answers/unix/check-for-new-file-exec-sqlplus/6714.html