LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 05-09-2006, 09:58 PM   #1
Xerop
Member
 
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.
<tab>Share_name<spaces>"Disk"<newline>

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, 08:48 PM   #2
Xerop
Member
 
Registered: Jan 2004
Distribution: Suse, Red Hat
Posts: 129

Original Poster
Rep: Reputation: 15
bump*
anyone? can someone show me how to just extract the names from the table?
 
Old 05-11-2006, 06:06 PM   #3
Xerop
Member
 
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
Code:

#!/bin/bash
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")
done
exec 3<&-


#COUNT=0
#       while [ $COUNT -lt 22 ]; do
#command        umount /mnt/server/${lines[$COUNT]}
#let COUNT=COUNT+1
#done

command smbclient -L -N //server

COUNTER=0
         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
         done
/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 06:10 PM.
 
Old 05-11-2006, 08:15 PM   #4
cs-cam
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, 08:45 AM   #5
archtoad6
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:
Code:
#!/bin/bash

# set the share table file
SHARES=<share_table_file>

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


Reply


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 01:33 AM
Samba domain member server (DMS) group permissions in network with a Samba PDC srosa Linux - Networking 0 05-01-2006 05:55 PM
I need the content from thegoldenear.org/toolbox/unices/samba/samba-setup.html rtg2001 Linux - Networking 1 08-05-2004 05:54 PM
Samba: Authenticate Linux-Clients in Samba Domain & Mount mule Linux - Software 0 12-10-2003 01:21 AM
when i restart SAMBA,it says:stop samba failed,start SAMBA OK! whepin Linux - Networking 3 12-26-2001 05:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:31 AM.

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