#!/usr/bin/ksh # # chk_asi_gunzip.ksh # # This script will check the gzipped ASI files # for discrepancies and if found will put them in the # problem directory # # creation date: 01-19-07 # # $1 = directory path to data # . /home/thmsoc/software_dev/config/ground_asi.config . /home/thmsoc/software_dev/config/soc_it_to_me.config ## Set some initial variables # its_here=$1 os=$(uname -s) processTime=$(date -u '+%Y-%m-%d %T') processCode=$its_here ## Determine which awk to use # if [[ $os = "SunOS" ]] then awk=nawk else awk=awk fi ## Make a list of the gzipped files that have just been ## copied off the disk # find $HIRES_COPY/staging/gunzip_review/${its_here} -name \*gz > /tmp/asi_gziplist.txt ## Now loop through results, generating input for MySQL tables and ## checking files for gzip errors. # while read line do fileName=$(basename $line) ucsite=$(echo $fileName |${awk} -F_ '{print toupper($3)}') mysql_table_name=GBO_${ucsite}_HIRES dataTime=$(echo $line |awk -F/ '{print $11 "-" $12 "-" $13 " " "00:00:00"}') fileSize=$(ls -l $line |awk '{print $5}') /home/thmsoc/software_dev/php/gbo_asi_hires_mirror_tbl_input_files.php $mysql_table_name $dataTime $fileName $processTime $processCode $fileSize test=$(gunzip -t $line 2>&1) if [[ -n $test ]] then # File failed test mysql_table_name_bad=${mysql_table_name}_BAD timecheck=$(echo $line |awk -F/ '{print $15}'|grep ut) if [[ -z $timecheck ]] then pathtofile=$(echo $line |awk -F/ '{print $11 "/" $12 "/" $13 "/" $14}') else pathtofile=$(echo $line |awk -F/ '{print $11 "/" $12 "/" $13 "/" $14 "/" $15}') fi mkdir -p ${HIRES_COPY}/you_bad/${pathtofile} mv $line ${HIRES_COPY}/you_bad/${pathtofile} /home/thmsoc/software_dev/php/gbo_asi_hires_mirror_tbl_input_bad_files.php $mysql_table_name $mysql_table_name_bad $fileName fi done < /tmp/asi_gziplist.txt /home/thmsoc/software_dev/ksh/mv_asi_hires.ksh rm /tmp/asi_gziplist.txt exit 0