bash script help?
Knute Johnson
ubuntu at knutejohnson.com
Mon Nov 14 15:51:53 UTC 2011
On 11/14/2011 2:09 AM, Colin Watson wrote:
> On Sun, Nov 13, 2011 at 09:40:47PM -0800, Knute Johnson wrote:
>> I've got a bash script that I run in cron.daily to backup some data
>> to a jump drive. One of the commands in my script is to umount the
>> drive. If I write;
>>
>> if umount /dev/sdb1; then
>> #do something
>> fi
>>
>> it always does it even if the umount is successful.
>
> The code above means "do something *only* if umount exits successfully".
> If you want to do something if umount fails, then you need:
>
> if ! umount /dev/sdb1; then
> # do something
> fi
>
Isn't something other than 0 true? umount should return false if it
fails to mount and in my example it would #do something if it failed to
unmount, yes?
Thanks,
--
Knute Johnson
More information about the ubuntu-users
mailing list