python - 在 Python 中使用 Samba 客户端将文件从 Linux 复制到 Windows
问题描述
我正在尝试将文件从 Linux 机器复制到 Windows 共享驱动器。此答案显示了如何使用 Samba 客户端执行此操作。在我的情况下,连接成功,listShares()
返回服务器上的共享但是当我打电话时connection.storeFile()
我得到Unable to connect to shared device
. 我错过了什么?
Linux机器上运行的python代码:
connection = SMBConnection(username='user1', password='password1', my_name='host1',remote_name='fs01',domain='domain', use_ntlm_v2=True)
connection.connect(ip, 139) # Returns true
file_obj = open(filename,"r")
connection.storeFile('\\\\fs01\\data\\folder1', file1, file_obj)
smb.smb_structs.OperationFailure: Failed to store data\folder1\file1 on fs01: Unable to connect to shared device
解决方案
推荐阅读
- javascript - 如何避免 useReducer(reducer, getInitialState()) 中使用的 getInitialState() 函数在每次渲染时运行?
- c# - 如何在关系数据库中存储 8 个或更多继承的 .net 类型
- java - struts2 强制将 https url 重定向到 http
- python - 如何从网页中读取内容,然后使用 urllib 将其输出
- javascript - 在 React 中使用 Filter 迭代两个不同的对象
- reactjs - 在 heroku 和 Github Pages 上部署 PWA 有什么区别
- javascript - 如何在 React 中为 JSON 中的每个项目创建唯一 ID?
- python - 如何在 python 中使用浮点数执行计算?
- java - 为上下文 [/appName] 修复“docBase”异常
- java - 如何让 RecyclerView 在片段中使用 SQLite 数据库中的项目?