使用 paramiko 将文件从远程目录复制到远程子目录 [英] Copy file from remote dir to remote sub directory using paramiko
本文介绍了使用 paramiko 将文件从远程目录复制到远程子目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将远程服务器中的文件 /maindir/fil1.txt
复制到子目录 /maindir/subdir/file1.txt
我有 sftp
使用 paramiko
创建.但它总是检查要从中复制的本地路径.
How to copy a file in a remote server /maindir/fil1.txt
to a sub directory /maindir/subdir/file1.txt
i have the sftp
created using paramiko
. But it always check for the local path to copy from .
filename_full_path='/maindir/fil1.txt'
destfilename_full_path='/maindir/subdir/file1.txt'
sftp.put(filename_full_path, destfilename_full_path)
如何告诉sftp本地路径也在远程主机中?
How to tell sftp that the local path is also in remote host?
推荐答案
你可以试试下面的方法
a=paramiko.SSHClient()
a.set_missing_host_key_policy(paramiko.AutoAddPolicy())
a.connect('ip',username='user',password='passw')
stdin, stdout, stderr = a.exec_command("cp /sourc/file /target/file")
这篇关于使用 paramiko 将文件从远程目录复制到远程子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文