Untar fail

Hi Team,

I have a file named as follows: aaa.tar.gz

Now I need to verify if the untar fails, then the script has to send a mail. In order to check this condition, I need a tar.gz file which is unable to untar it. Can anyone help me to create a file which I will be able to unzip successfully but unable to untar.

We are working on AIX 6.1 Env.

Can anyone help me to fix this issue?

Thank you.

Well, from what I gather, you want to create a broken tar file to test your script. Is that right? You could do a quick search and find out more pages like this one here.

Or you could use the exit status variable $? to determine if the untar is a success or not.

tar zxf aaa.tar.gz
if [ $? -ne 0 ]
then
  echo "Untar failed" | mail -s "Untar failed" someone@something.com
fi
1 Like

Thank you for your reply.