Paramiko 使用 put 时出错
您好,我在 microsoft windows xp v2002 service pack3 上使用 paramiko 1.7.6“fanny” 和 python 2.4.2
我有以下脚本:
import paramiko
hostname='blah'
port=22
username='blah'
password='blah'
fullpath='\\\\root\\path\\file.xls'
remotepath='/inbox/file.xls'
self.client= paramiko.SSHClient()
self.client.load_system_host_keys()
self.client.connect(hostname,port,username,password)
sftp = self.client.open_sftp()
sftp.put(fullpath,remotepath)
我得到的错误是:
sftp.put(fullpath,remotepath))
File "build\bdist.win32\egg\paramiko\sftp_client.py", line 577, in put
File "build\bdist.win32\egg\paramiko\sftp_client.py", line 337, in stat
File "build\bdist.win32\egg\paramiko\sftp_client.py", line 628, in _request
File "build\bdist.win32\egg\paramiko\sftp_client.py", line 675, in _read_response
File "build\bdist.win32\egg\paramiko\sftp_client.py", line 701, in _convert_status
IOError: [Errno 2] /inbox/file.xls is not a valid file path
但路径肯定存在(我可以使用 sftp.chdir 移入它) ('收件箱')) 我 也尝试过移入文件夹并使用 put 但我得到完全相同的结果 错误(是否删除了收件箱前缀)
有人遇到过这个问题吗?
干杯 马特
Hi I am using paramiko 1.7.6 "fanny" on microsoft windows xp v2002 service pack3 with python 2.4.2
I have the follwing script:
import paramiko
hostname='blah'
port=22
username='blah'
password='blah'
fullpath='\\\\root\\path\\file.xls'
remotepath='/inbox/file.xls'
self.client= paramiko.SSHClient()
self.client.load_system_host_keys()
self.client.connect(hostname,port,username,password)
sftp = self.client.open_sftp()
sftp.put(fullpath,remotepath)
the error I get is:
sftp.put(fullpath,remotepath))
File "build\bdist.win32\egg\paramiko\sftp_client.py", line 577, in put
File "build\bdist.win32\egg\paramiko\sftp_client.py", line 337, in stat
File "build\bdist.win32\egg\paramiko\sftp_client.py", line 628, in _request
File "build\bdist.win32\egg\paramiko\sftp_client.py", line 675, in _read_response
File "build\bdist.win32\egg\paramiko\sftp_client.py", line 701, in _convert_status
IOError: [Errno 2] /inbox/file.xls is not a valid file path
but the path definitely exists (I can move into it using sftp.chdir('inbox')) I
have also tried moving into the folder and using put but I get the exact same
error (did take out inbox prefix)
Has anyone had this issue?
Cheers
matt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
IOError: [Errno 2] /inbox/file.xls 不是有效的文件路径
这是您的错误,这意味着 /inbox 不是有效的路径。您可能打算使用
remotepath='inbox/file.xls'
IOError: [Errno 2] /inbox/file.xls is not a valid file path
This is your error, which means that /inbox isn't a valid path. You probably meant to use
remotepath='inbox/file.xls'
我有同样的问题。
签名指定sftp_client.py
def put(self,localpath,remotepath,callback = None,confirm = True):
大多数论坛的回答都将第一个参数称为remotepath。
如果我们将第一个更改为本地路径,将第二个更改为远程路径,
效果很好。
这没有问题。
I had the same issue.
The signature specifies sftp_client.py
def put(self, localpath, remotepath, callback=None, confirm=True):
most of the forums answered referred the first argument as remotepath.
if we change the first one as local path and the second one as remote path,
it works fine.
No issues with this.