我正在尝试使用 Python 访问我们的 Samba 服务器上的文件。我发现我需要为此使用 Samba 客户端,所以我开始使用 PySmbClient。尽管网上有很多关于如何做到这一点的例子,但我的只是不想工作。见下文。
smb = smbclient.SambaClient(server="192.168.0.320", share="DATA", domain="WORKGROUP",username="admin", password="abc123")
f = smb.open('test.json', 'r')
这会产生以下错误:
OSError: [Errno 2] No such file or directory
带有以下跟踪:
Traceback (most recent call last):
File "create_dataset.py", line 35, in <module>
f = smb.open('serverSaver.txt', 'r')
File "/home/grant/Development/create_dataset/env/local/lib/python2.7/site-packages/smbclient.py", line 408, in open
f = _SambaFile(self, path, mode)
File "/home/grant/Development/create_dataset/env/local/lib/python2.7/site-packages/smbclient.py", line 448, in __init__
connection.download(remote_name, self._tmp_name)
File "/home/grant/Development/create_dataset/env/local/lib/python2.7/site-packages/smbclient.py", line 393, in download
result = self._runcmd('get', remote_path, local_path)
File "/home/grant/Development/create_dataset/env/local/lib/python2.7/site-packages/smbclient.py", line 184, in _runcmd
return self._raw_runcmd(fullcmd)
File "/home/grant/Development/create_dataset/env/local/lib/python2.7/site-packages/smbclient.py", line 168, in _raw_runcmd
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
我已经阅读并实施了许多“解决方案”,但到目前为止,没有什么对我有用。我可以通过我的文件管理器使用给定的凭据访问 Samba 服务器,所以我知道这些值应该没问题。我什至与我们的系统管理员交谈过,他不知道可能出了什么问题。
它一定不仅仅是我写的简单代码。你认为服务器端有问题吗?我输入到 SambaClient 中的值是什么?在这一点上,我对任何导致解决方案的事情都持开放态度。