1
我试图从SFTP服务器复制文件。 我可以使用python pysftp进行连接。 我可以运行:python pysftp [Errno 13] Permission denied:
data = srv.listdir()
for i in data:
print I
然后我得到目录列表。但是,当我尝试
sftp.put (localpath,"file_name.txt")
我得到
"IOError: [Errno 13] Permission denied: 'C:\....."
我有权限到该文件夹,因为我可以运行MKDIR并创建该文件夹目录。我已经尝试了许多不同的方法,但迄今为止没有运气,任何帮助都是真正的赞赏。
import pysftp
import os
def sftpExample():
cnopts = pysftp.CnOpts()
cnopts.hostkeys = None
with pysftp.Connection('HOST', username='username', password='Password', cnopts=cnopts) as sftp :
print 'connected '
localpath="C:\\new project\\new"
remotepath="/folder1"
sftp.put(localpath,"infso.txt")
sftp.put(localpath,remotepath)
sftp.getfo (remotepath, localpath)
srv.get_r(localpath, remotepath)
srv.close()
sftpExample()
我得到这个错误代码:
Traceback (most recent call last):
File "db_backup.py", line 42, in <module>
sftpExample()
File "db_backup.py", line 17, in sftpExample
sftp.put(localpath,"GT-Dallas SFTP infso.txt")
File "c:\Python27\lib\site-packages\pysftp\__init_.py", line 364, in put
confirm=confirm)
File "c:\Python27\lib\site-packages\paramiko\sftp_client.py", line 720, in put
with open(localpath, 'rb') as fl:
IOError: [Errno 13] Permission denied: "C:\\new project\\new"
我已经尝试了所有不同的方式,你看,但是我已经没有运气迄今复制的文件。