Bash script conditions
Stuart Jansen
sjansen at buscaluz.org
Wed Jul 12 06:46:04 MDT 2006
On Wed, 2006-07-12 at 06:22 -0600, Jonathan Duncan wrote:
> I just do not know the syntax. I saw a list of "Exit Values" in the rsync
> man page but how do I check for those?
If you don't care about the exact return code in event of an error, you
can include the rsync command in the if statement.
if rsync foo bar baz
then
echo success
else
echo failure
fi
If you care about the return code, immediately after running rsync, add
RC=$?
The variable $? contains the return code of the last command to execute.
if [ 0 -eq $RC ]
then
echo "Shells are weird, 0 == success == true"
fi
Check the builtin bash help for test
help test
to find out about the various types of tests.
--
Stuart Jansen e-mail/jabber: sjansen at buscaluz.org
google talk: stuart.jansen at gmail.com
"However beautiful the strategy, you should occasionally look at
the results." -- Winston Churchill
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://plug.org/pipermail/plug/attachments/20060712/c9f0ed46/attachment.pgp
More information about the PLUG
mailing list