Jump to content

Samba mount question.


tvlad
 Share

Recommended Posts

I know that i can acces a windows share by typing :

smbount //share_name/dir.

 

But i would like to know how i could mount everything that he is sharing.I mean : if he has 5 directorys shared, i want to mount them all let's say to /home.

 

I tried with smbmount //share_name, but i also have to specify a dir, i can't just mount everything he's sharing.

Link to comment
Share on other sites

  • 2 weeks later...
Guest southernguy
I know that i can acces a windows share by typing :

smbount //share_name/dir.

 

But i would like to know how i could mount everything that he is sharing.I mean : if he has 5 directorys shared, i want to mount them all let's say to /home.

 

I tried with smbmount //share_name, but i also have to specify a dir, i can't just mount everything he's sharing.

 

why u dont just put the shares all in fstab with his machine have its own dir under /home/ but each share also have a dir?

 

/home/winbox/share1

/home/winbox/share2

 

and so on? or write a script that mounts them all and when you want to mount them all just call the script.

Link to comment
Share on other sites

  • 1 month later...

:idea: With a script like the following You should be able to mount Windows shares on request, even if You don't know all shares or even all machine names (but You must know the Administrator password on Win2000 machines):

---------------<BOF>-------------------

:arrow: #!/bin/sh

# get NETbios names that accesses eth0 (or whatever

# interface Your LAN is connected with) from ARP-Table

# This is done within he first awk program, that does not

# prompt for input, since it gets none (input from null device)

:arrow: awk 'BEGIN {while (("/sbin/arp -va"|getline) > 0)

:arrow: if ($NF ~/eth0/) print $1; close("/sbin/arp -va")}' /dev/null |

# ... separate <Machine.Workgroup> and print two

#lines "Machine=<hostname>" and "Workgroup=<Workgroup>"

#pipe output to awk to make directories for each windows host

:arrow: awk 'BEGIN {FS="."}

:arrow: {Machine=$1;Workgroup=$2

:arrow: system("mkdir -p /NetworkNeighborhood/"$1)}'

#get the windows hosts from the newly reated directories, pipe to

#awk once more (this script discards the workgroup names)

:arrow: ls -l /NetworkNeighborhood|awk '

:arrow: {if ($1 ~ /^d.*/) {

:arrow: Client=$NF

:arrow: Shares = "/usr/bin/smbclient -UAdministrator%adminpassword -L "Client

:arrow: while ((Shares| getline) > 0)

:arrow: print "/"Client"/",$0

:arrow: close(Shares)}

:arrow: }'|

# The output of the smbclient utility is piped a last time to awk,

# each line preceded by the windows host's name within slashes

# so the sequence $1$1 holds /<hostname>/<sharename>

# The awk program creates the moountpoints and mounts the

# shares, discarding shares like ADMIN$, C$ in the if-condition

:arrow: awk '$3~/[Dd]isk/ { if ($2~/[^$]$/) {

:arrow: Clientshare=$1$2

:arrow: Mountpoint="/NetworkNeighborhood"Clientshare

:arrow: system("mkdir -p "Mountpoint)

:arrow: system("/usr/bin/smbmount /"Clientshare" "Mountpoint" -o username=Administrator%miez")

:arrow: }

:arrow: }'

-----<EOF>----------

as root, copy that script to, let us say, /usr/bin/smbconnect (and get rid of those :arrow:s :oops: ). The SETUID-flag of the script must be set.

 

Create a new KDE desktop Iconnamed "Network Neighborhood" as a link to a program. It should execute the command line

"/usr/bin/smbconnect;konqueror "/NetworkNeighborhood".

All together will do much the same as a doubleclick on the Network Neighborhood's icon on Your windows desktop.

Another way would be to call that script on any login.

BUGS: arp might fail when the connection(s) to the windows host(s) is/are idle for a while. Consider calling the smbconnect script in Your login script, when there was traffic from samba startup while booting. Don't call it before login, or all windows shares would belong to root for that session.

 

You might want to remove the directories of all the windows shares when shutting down your linux box. DON'T FORGET to smbumount ALL SHARES befor You do that!

 

Have fun...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...