从Ubuntu上,我可以使用pysmb连接到Windows网络共享,然后列出所有可用的共享,并列出该共享根目录下的所有文件和文件夹,但在树的下方没有任何内容。我需要在共享路径中访问5个文件夹级别的文件夹,才能将文件复制到该位置,并且不能超过文件共享的根级别。
我尝试在路径之间使用正斜杠和反斜杠(单双),并尝试以任何一种方式包括和排除尾随斜杠。我只尝试了1个级别,并且也尝试了每个级别。
from smb.SMBConnection import SMBConnection
userid = 'myid'
password = 'mypassword'
client = 'clientMachine'
remote = 'remoteMachine'
server_ip = '5.5.5.5'
conn = SMBConnection(userid, password, client, remote, domain='MYDOM',use_ntlmv2 = True)
assert conn.connect(server_ip, 139)
sharelist = conn.listShares()
for s in sharelist:
print(s.name)
filelist = conn.listPath('Shared','/')
for f in filelist:
print(f.filename)
conn.close()
如果我在listPath调用中包含除“ /”以外的任何其他路径,即使我尝试的路径已在打印语句中列出,我仍找不到该路径:
Traceback (most recent call last):
File "testsmb.py", line 14, in <module>
filelist = conn.listPath('Shared', '/Corp/')
File "/usr/local/lib/python2.7/dist-packages/smb/SMBConnection.py", line 202, in listPath
self._pollForNetBIOSPacket(timeout)
File "/usr/local/lib/python2.7/dist-packages/smb/SMBConnection.py", line 630, in _pollForNetBIOSPacket
self.feedData(data)
File "/usr/local/lib/python2.7/dist-packages/nmb/base.py", line 54, in feedData
self._processNMBSessionPacket(self.data_nmb)
File "/usr/local/lib/python2.7/dist-packages/nmb/base.py", line 75, in _processNMBSessionPacket
self.onNMBSessionMessage(packet.flags, packet.data)
File "/usr/local/lib/python2.7/dist-packages/smb/base.py", line 145, in onNMBSessionMessage
if self._updateState(self.smb_message):
File "/usr/local/lib/python2.7/dist-packages/smb/base.py", line 339, in _updateState_SMB2
req.callback(message, **req.kwargs)
File "/usr/local/lib/python2.7/dist-packages/smb/base.py", line 638, in createCB
errback(OperationFailure('Failed to list %s on %s: Unable to open directory' % ( path, service_name ), messages_history))
File "/usr/local/lib/python2.7/dist-packages/smb/SMBConnection.py", line 196, in eb
raise failure
smb.smb_structs.OperationFailure: Failed to list Corp on Shared: Unable to open directory
我需要进入嵌套在这里的共享:
//remotemachine/Shared/Corp/Futher/Futher with Space/Yet another Space/Test
我可以看到所有共享,甚至可以看到每个共享根目录级别中的文件和文件夹,但是没有更进一步的信息。我在所有级别中都有权限,我缺少什么?