J Gao
2012-Dec-17 22:29 UTC
[Samba] Bash question about find out all accessible shares on Samba server
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. Gao --
Moray Henderson
2012-Dec-19 09:41 UTC
[Samba] Bash question about find out all accessible shares on Samba server
> -----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. Moray. "To err is human; to purr, feline."