linux读取不到共享服务器的文件,如何使用python从Linux服务器读取Windows共享文件夹中的数据...

博客内容描述了如何使用Python和smbclient模块从远程Windows共享文件夹中列出并下载PDF文件。作者遇到的问题是需要将大文件传输到Linux服务器才能处理,询问是否存在直接在远程文件上操作的解决方案。
摘要由CSDN通过智能技术生成

在我目前的情况下,我的Linux服务器上有一个python脚本,可以处理远程windows共享文件夹中的一些pdf文件。我目前正在使用smbclient连接到它,但我无法处理文件,可能我需要首先将所有文件传输到我的Linux服务器,因为所有文件的大小都可能非常大。在这种情况下,我还能做什么呢?有没有一种方法可以创建一个管道,让python脚本在其中运行,并使用这些文件给出结果。你知道吗

代码如下:from smb.SMBConnection import SMBConnection

userID = '---------'

password = '-------'

client_machine_name = '-----'

server_name = ' '

server_ip = '...'

domain_name = '-------'

conn=SMBConnection(userID,password, client_machine_name, server_name,

domain=domain_name, use_ntlm_v2=True,is_direct_tcp=True)

conn.connect(server_ip, 445)

shares = conn.listShares()

# storing file names in a list

dirlist = []

for share in shares:

if not share.isSpecial and share.name not in ['NETLOGON', 'SYSVOL']:

sharedfiles = conn.listPath(share.name, '/DMDA_2.0_Files/ProcessedBatchDocPdfs/12345678')

for sharedfile in sharedfiles:

print(sharedfile.filename)

dirlist.append(sharedfile.filename)

# retrieve or download file

path = 'DMDA_2.0_Files/ProcessedBatchDocPdfs/12345678/111111.pdf'

with open('abc.pdf','wb') as f:

conn.retrieveFile(share.name, path, f)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值