Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 05-09-2006, 10:58 PM   #1
Registered: Jan 2004
Distribution: Suse, Red Hat
Posts: 129

Rep: Reputation: 15
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!
Old 05-10-2006, 09:48 PM   #2
Registered: Jan 2004
Distribution: Suse, Red Hat
Posts: 129

Original Poster
Rep: Reputation: 15
anyone? can someone show me how to just extract the names from the table?
Old 05-11-2006, 07:06 PM   #3
Registered: Jan 2004
Distribution: Suse, Red Hat
Posts: 129

Original Poster
Rep: Reputation: 15
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

Last edited by Xerop; 05-11-2006 at 07:10 PM.
Old 05-11-2006, 09:15 PM   #4
Senior Member
Registered: May 2004
Location: Australia
Distribution: Gentoo
Posts: 3,545

Rep: Reputation: 57
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
Old 05-15-2006, 09:45 AM   #5
Senior Member
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
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 


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Samba/Cups print sharing problems (/var/spool/samba files) Gates1026 Linux - General 9 06-23-2013 02:33 AM
Samba domain member server (DMS) group permissions in network with a Samba PDC srosa Linux - Networking 0 05-01-2006 06:55 PM
I need the content from rtg2001 Linux - Networking 1 08-05-2004 06:54 PM
Samba: Authenticate Linux-Clients in Samba Domain & Mount mule Linux - Software 0 12-10-2003 02:21 AM
when i restart SAMBA,it says:stop samba failed,start SAMBA OK! whepin Linux - Networking 3 12-26-2001 06:54 AM > Forums > Linux Forums > Linux - Software

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration