开发者

automatic Samba share script

开发者 https://www.devze.com 2023-03-16 10:24 出处:网络
I have an Ubuntu 10.04 server running Samba. I want to write a script (for Linux or Windows computer) that, given the IP of this server and the path of the shared Samba folder, can automatically cre

I have an Ubuntu 10.04 server running Samba.

I want to write a script (for Linux or Windows computer) that, given the IP of this server and the path of the shared Samba folder, can automatically create a "network drive"开发者_运维知识库 icon on the desktop. Both machines are on a local network.

I realize this will be different for linux/windows.

Any suggestions? I'm just not sure where to start. Thanks!


For Windows machines, you want to look at net use. For instance, to map the share "Data" on 192.168.0.2 to Z:, you'd write net use Z: \\192.168.0.2\Data. There is a lot of options, so check net help use for a complete list. For instance, you might want to look at /persistent, which would automatically recreate the share every time you log in. Or you could put this in a .BAT file which is executed when logging in.

On linux, I think you'd generally have to be root to do this, as it'd require a mount command. I know some desktop environments (such as GNOME) get around this, but to acually mount it you need root. The command to mount the same share at the mountpoint /mnt/Data would simply be mount //192.168.0.2/Data /mnt/Data, if you allow anyone access. If you require a logon, you need to add -o User=YOURUSER. You will then be prompted for a password. (Note that this requires the CIFS/SMB drivers to work)

0

精彩评论

暂无评论...
验证码 换一张
取 消