简体   繁体   English

使用python通过UNC路径将文件复制到linux机器

[英]copy file to linux machine via UNC path using python

I need to copy a file from a distributed storage network to my linux machine. 我需要将文件从分布式存储网络复制到Linux机器。 I only get the UNC path to the file from a database. 我只从数据库获取文件的UNC路径。 There are about 20 servers with more than 30 shares on each server, so mounting them local with samba is not a good option. 大约有20台服务器,每台服务器上都有30多个共享,因此用samba在本地安装它们不是一个好选择。

i tried open(r'\\\\filestore01\\share01\\00\\000001', 'r') on a Windows machine, which works, but not on linux. 我在Windows机器上尝试了open(r'\\\\filestore01\\share01\\00\\000001', 'r') ,但是可以在Linux上运行。 I also found Python Linux-copy files to windows shared drive (samba) which will again mount before copy... 我还发现Python Linux复制文件到Windows共享驱动器(samba) ,它将在复制之前再次挂载...

is that the only solution available? 那是唯一可用的解决方案吗? is there no native lib to copy from a windows share? 有没有要从Windows共享复制的本机lib?

The best solution to the problem, to avoid mounting things everywhere, is to use libraries like pysmb: https://pythonhosted.org/pysmb/api/smb_SMBConnection.html 为了避免将问题挂到各处,对该问题的最佳解决方案是使用pysmb之类的库: https ://pythonhosted.org/pysmb/api/smb_SMBConnection.html

Probably the best idea would be to write a wrapper for such URLs. 最好的主意可能是为此类URL编写包装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM