Computing.Net > Forums > Linux > Check gz files when corruption !

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Check gz files when corruption !

Reply to Message Icon

Name: hoan0202
Date: November 9, 2007 at 12:25:10 Pacific
OS: OS
CPU/Ram: 512
Product: Dell
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


replace \ with \\ using b... Linux WeatherBug applet a...



Post Locked

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


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: Check gz files when corruption !

can't install .tar.gz file www.computing.net/answers/linux/cant-install-targz-file/22135.html

tar.gz files www.computing.net/answers/linux/targz-files/15953.html

need help on tar.gz. file type www.computing.net/answers/linux/need-help-on-targz-file-type/20645.html