gunzip status

Hi,
I'm trying to run my application on HP-UX server.
I have to extract a *.tar.gz file.
I'm doing that now in 2 steps.
first I gunzip it and then pax it.
My question is how can I check whether the data in the *.tar.gz file is corrupted or not??

Now, I'm trying to do this

gunzip_status=`gunzip -f $dir1/$filename.tar.gz`
if { ( echo $gunzip_status | grep invalid >/dev/null ) } then
            echo "$filename.tar.gz is corrupted "
            mailx -s "File $filename.tar.gz is corrupted "        email@server.com < gunzip_err.txt
        else
            pax -v -r -s ',//*log_recv/di/data/interface//*,,' -f $filename.tar
        fi

and it is not working :frowning:
Any advice???? cos there are chances that the incoming file maybe corrupted.

Read man gunzip ("gunzip") manual for option. I'll suggest gunzip -qt file and test the exit value $? , 0 is OK , anything else is failure.