Re: Checking for a mount in a shell script
- To: debian-user@lists.debian.org
- Subject: Re: Checking for a mount in a shell script
- From: Kamil Jońca <kjonca@o2.pl>
- Date: Tue, 20 May 2025 07:41:41 +0200
- Message-id: <[🔎] 8734cz96ui.fsf@alfa.kjonca>
- In-reply-to: <KNPQ5-41IW-1@gated-at.bofh.it> (Andy Smith's message of "Sun, 18 May 2025 19:20:01 +0200")
- References: <KNPn3-41ii-1@gated-at.bofh.it> <KNPQ5-41IW-1@gated-at.bofh.it>
Andy Smith <andy@strugglers.net> writes:
> Hi,
>
> On Sun, May 18, 2025 at 12:47:25PM -0400, Default User wrote:
>> Since I know almost no shell scripting, the rsync usb drive A
>> to usb drive B copy is done with a simple bash script consisting
>> only of the rsync backup command, with options and parameters, but
>> without any code to verify that usb drive B is attached.
>>
>> I really should learn more shell scripting. That is something
>> else I will get to "Real Soon Now".
>> :)
>
> If your backup script is a bash script then all you need do is put
> something like:
>
> if ! findmnt /mnt/usb-drive-b; then
> echo "Mount USB drive B before running this!" >&2
> exit 1
> fi
why not
if ! mountpoint /mnt/usb-drive-b ; then ...
?
KJ
--
http://wolnelektury.pl/wesprzyj/teraz/
EMACS = Even a Master of Arts Comes Simpler
Reply to: