Check to see if share is mounted

Jerry jerry at seibercom.net
Tue Oct 29 14:51:30 UTC 2013


On Tue, 29 Oct 2013 12:55:08 +0100
Polytropon articulated:

> That's quite easy. Just query "df" and grep for the name of
> the mountpoint or the CIFS name ("device field" as it appears
> in /etc/fstab). Here's an example:
> 
> 	if [ df | grep "/home/bob/stuff" ]; then
> 		... do stuff when share is mounted ...
> 	else
> 		echo "CIFS share not availble."
> 		exit 1
> 	fi

That doesn't work under Bash. I modified it and now it works fine.

if ( df | grep 'Path_To_Mount' &>\dev\null ); then
	echo "It is mounted"
else                                                            
	echo "Not mounted"                                                                                                                              
fi 

-- 
Jerry ♔

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the Reply-To header.
__________________________________________________________________



More information about the freebsd-questions mailing list