--------------------------------------------------
From: "Binand Sethumadhavan" <[email protected]>
Sent: Monday, November 22, 2010 9:19 AM
To: "GNU/Linux Users Group, Mumbai, India" <[email protected]>
Subject: Re: [ILUG-BOM] running script only if USB is mounted

> 2010/11/22 Kshitiz <[email protected]>:
>> Before running the rsync copying script, I want to
>>    a) Add some statement that would check if the external harddisk is 
>> attached and mounted.
>>    b) If not, it should be mounted before the copying script is run to 
>> copy only to this external disk.
>>    c) If it is not mounted, mount should be attempted, and if it does not 
>> mount, rsync copying command should not be executed.
>
> All mounted filesystems have an entry in /proc/mounts. Your script can
> take advantage of this.
>
> if ! grep -q /backup /proc/mounts; then
>    if ! mount -t ext3 /dev/sdb1 /backup; then
>        exit 1; # Mount failed, bail out
>    fi
> fi
>
> # Regular stuff here
> -- 
> http://mm.glug-bom.org/mailman/listinfo/linuxers
>

Thank you Binand Reg Kshitiz 

-- 
http://mm.glug-bom.org/mailman/listinfo/linuxers

Reply via email to