Re: [Nolug] Bash backup script help

From: -ray <ray_at_ops.selu.edu>
Date: Fri, 22 Jun 2007 16:55:30 -0500 (CDT)
Message-ID: <Pine.LNX.4.61.0706221652490.16480@romulus.csd.selu.edu>

On Fri, 22 Jun 2007, Chris Jones wrote:

> The functionality I'm wanting to add to it, is after the TAR/GZIP operation,
> I want it to know if the tar command completed successfully or with errors.
> If there were errors, then skip the deletion process. The skipping part is
> easy, but I guess the main thing I'm wondering is how do I test whether the
> tar command ran successfully? I remember in DOS, after you run a command,
> you can test it with "IF ERRORLEVEL=0" and if that returns true then you
> know the command completed successfully. What's the unix equivalent?

It's similar in unix, using the $? variable. Most commands will exit
non-zero status if there's a problem, and exit zero status if there's no
problem. Based on this, run this code immediately after the tar command:

if [ $? != 0 ]; then
         echo "tar exitted non-zero. Let's not delete"
         exit 1
fi

ray

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Ray DeJean  				       	 http://www.r-a-y.org
Systems Engineer                    Southeastern Louisiana University
IBM Certified Specialist  	      AIX Administration, AIX Support
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
___________________
Nolug mailing list
nolug@nolug.org
Received on 06/22/07

This archive was generated by hypermail 2.2.0 : 12/19/08 EST