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"
我已經嘗試了所有不同的方式,你看,但是我已經沒有運氣迄今複製的文件。