-   Linux - Software (
-   -   automouter samba (

Xerop 05-09-2006 09:58 PM

automouter samba
I need a script or some sort of software that would be able to check the available shares on a specific target machine (with smbclient or smbmount) make directories for each share in a specific folder then loop through and mount all available shares. I need this script because I have a scpecific computer that constantly changes its shares and I am tired of manualy mounting each needed share. If someone could point me in the right direction I would be greatful.

I can get a list of shares in the following table format.

a Disk
asdas Disk
lakjsh Disk
l;akjsd Disk

replace <tab> with a tab character and <spaces> with spaces.
If someone could tell me how to extract the share name by it self from maybe 10 lines (with a loop)
I also would like to set a variable equal to one of the share names and mount it then loop through all the lines to complete the mounting.

This should end up to be a simple bash script or sh script that could be run at the start of kde!

Xerop 05-10-2006 08:48 PM

anyone? can someone show me how to just extract the names from the table?

Xerop 05-11-2006 06:06 PM

well I compiled the solution on my own using some online scripts. I do not know bash so this might not be optimal but it works

declare -a lines
exec 3</home/user/smb || exit 1
while read curline <&3; do
    if [ -z "$curline" -o "${curline:0:1}" = "#" ]; then continue; fi
    lines=("${lines[@]}" "$curline")
exec 3<&-

#      while [ $COUNT -lt 22 ]; do
#command        umount /mnt/server/${lines[$COUNT]}

command smbclient -L -N //server

        while [  $COUNTER -lt 22 ]; do
            echo mounting //server/${lines[$COUNTER]}
command smbmount //server/${lines[$COUNTER]} /mnt/server/${lines[$COUNTER]} -o guest
#      sleep 1
            let COUNTER=COUNTER+1

/home/user/smb is the path to the file which contains the share names. //server is the samba name of your pc which has the shares. maybe this will help someone

cs-cam 05-11-2006 08:15 PM

Excellent work! I only just saw this thread which is weird but hey, great job working it out and thank you for taking the time to post it for others :)

archtoad6 05-15-2006 08:45 AM

I too just saw this, & echo the 2 compliments.

I do think your script could be way simpler, or else I don't understand what you are trying to do. Assuming your "list of shares in the following table format" is in a file (SHARES) & the command that will mount a share is smbmount //server/share /mnt/server/share -o guest where "share" is the current share, then would this not work:


# set the share table file

for S in `awk '{print $1}' $SHARES`
  smbmount //server/$S /mnt/server/$S -o guest

All times are GMT -5. The time now is 03:23 AM.