[Samba] Bash question about find out all accessible shares on Samba server

Moray Henderson Moray.Henderson at ict-software.org
Wed Dec 19 02:41:15 MST 2012

> -----Original Message-----
> From: J Gao [mailto:jgao at veecall.com]
> Sent: 17 December 2012 22:30
> Hello,
> I am working on a bash script to help user mount Samba share on his/her
> local Linux (Ubuntu) system. Now I can list all the Samba shares by
> command:
> #smbclient -N -gL \\sambaserver 2>&1 | grep -e "Disk|" | cut -d'|' -f2
> The problem is we have too many shares on the server so this come out a
> very long list of all the shares. Now I only want to list the user
> accessible shares and hide all others. I can use "read" to get user's
> login name/password for Samba authorization. Is there a way I can get
> the share list based on user's permission?
> Thanks for help.

If you don't use -N for smbclient it will try to connect as the user who is
logged in, prompting them for their password.  If that doesn't list only the
shares you want, you can pass the list to a 'for' loop, try to access each
one and build a new list from that.

"To err is human; to purr, feline."

More information about the samba mailing list