我正在尝试编写脚本来从我的桌面PC中复制RaspberryPi中的文件。 这里是我的代码:(一部分)python在本地网络中复制文件(linux - > linux)并输出
print "start the copy"
path_pi = '//192.168.2.2:22/home/pi/Stock/'
file_pc = path_file + "/" + file
print "the file to copy is: ", file_pc
shutil.copy2(file_pc, path_pi + file_pi)
其实我有这样的错误:(法语)
IOError: [Errno 2] Aucun fichier ou dossier de ce type: '//192.168.2.2:22/home/pi/Stock/exemple.txt'
所以,我怎么能继续吗?在尝试复制之前,我必须连接2台机器吗? 我已经tryed有:
path_pi = r'//192.168.2.2:22/home/pi/Stock'
但问题是一样的。 (和file_pc是一个变量)
感谢
编辑: 好吧,我发现这一点:
command = 'scp', file_pc, file_pi
p = subprocess.Popen(command, stdout=subprocess.PIPE)
但是没有办法有输出...(与壳牌=假工作)
相关:我如何使用scp或ssh将文件复制到Python中的远程服务器?](HTTP:/ /stackoverflow.com/q/68335/4279) – jfs