[Samba] Bash/perl: how to know if a samba directory is mounted?

Arc C. achapkis at dls.net
Wed Sep 6 15:46:03 GMT 2006


  You can also move the mounting/unmounting out of your perl app and let
automounter take care of it. Here's how I've done that:

# grep moshe /etc/auto.master
/moshe  /etc/auto.moshe
# cat /etc/auto.moshe
#
# $Id: auto.misc,v 1.2 2003/09/29 08:22:35 raven Exp $
#
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# Details may be found in the autofs(5) manpage

temp
-fstype=cifs,username=linux,password=somepasswd,iocharset=cp1251,codepage=866
://moshe/temp
photos
-fstype=cifs,username=linux,password=somepasswd,iocharset=cp1251,codepage=866
://moshe/photos


 So, for example, if I wait long enough (default timeout value for automap is
5 min, man automount) and then do:
# df|grep moshe

  I don't see anything. Now I do:
# cd /moshe/temp
# df .
//moshe/temp         117217276  85239632  31977644  73% /moshe/temp
# mount -v|grep "moshe/temp"
//moshe/temp on /moshe/temp type cifs (rw,mand)

> 
> Luca,
> 
> On 9/6/06, Luca Manganelli <luca76 at gmail.com> wrote:
> > Hi,
> >
> > I am writing an Perl application that automatically mounts 
> a samba directory.
> >
> > But I would like to know if that directory is already 
> mounted by samba 
> > (i.e. in multiple logins, that directory could be mounted 
> only on the 
> > first login) ?
> > --
> > To unsubscribe from this list go to the following URL and read the
> > instructions:  https://lists.samba.org/mailman/listinfo/samba
> >
> 
> why not:
> MOUNTED=`mount|grep <mounted_directory>` if [ ! -n $MOUNTED ]; then
>     mount <yur_dir>
> fi
> 
> Cheers,
> --
> Rory Vieira
> rory dot vieira at gmail dot com
> --
> To unsubscribe from this list go to the following URL and read the
> instructions:  https://lists.samba.org/mailman/listinfo/samba
> 



More information about the samba mailing list