Paramiko 使用 put 时出错

发布于 2024-10-09 13:48:05 字数 1106 浏览 0 评论 0原文

您好,我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

笑着哭最痛 2024-10-16 13:48:05

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'

丢了幸福的猪 2024-10-16 13:48:05

我有同样的问题。

签名指定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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文