所以我找到了一个允许我挂载共享的代码。但我想将多个共享挂载到系统中。每个主机都将安装到本地系统上的相应文件夹中。我做了以下但是真的没有成功,所以试图找出我将如何做到这一点。使用下面的代码。
#!/usr/bin/env python
import os
USER = "sambauser"
HOSTS = ["10.1.1.x", "10.1.1.x", "10.1.1.x", "10.1.1.x", "10.1.1.x"]
SHARES = ["n", "b", "m", "k", "w"]
for entry in SHARES:
os.popen("mount -t cifs //%s/%s /r/loads/%s -o username=%s"%(HOSTS, entry, entry, USER)
print "Mounted %s" %(entry)
print "done"
答案 0 :(得分:0)
类似的东西应该有助于让你指向正确的方向。
#!/usr/bin/env python
import os
USER = "sambauser"
HOSTS = ["10.1.1.x", "10.1.1.x", "10.1.1.x", "10.1.1.x", "10.1.1.x"]
SHARES = ["n", "b", "m", "k", "w"]
for share in SHARES:
for host in HOSTS:
os.popen("mount -t cifs //%s/%s /r/loads/%s -o username=%s"%(host, share, share, USER)
print "Mounted //%s/%s on /r/loads/%s as %s" % (host, share, share, USER)
print "done"