python open no such file_使用paramiko的sftp时出现“No such file”错误

我想使用python将本地文件传输到服务器#!/usr/bin/env python

import os

import paramiko

ssh = paramiko.SSHClient()

ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

ssh.connect(hostname, username="username", password="password")

ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command('ls /tmp')

print "output", ssh_stdout.read()

#Reading output of the executed command

error = ssh_stderr.read()

#Reading the error stream of the executed command

print "err", error, len(error)

#Transfering files to and from the remote machine

sftp = ssh.open_sftp()

#sftp.get("/home/developers/screenshots/ss.txt", "/home/e100075/python/ss.txt")

sftp.put('/home/e100075/python/ss.txt', '/home/developers/screenshots/ss.txt')

sftp.close()

ssh.close()

在运行之后,我得到了下面的错误File "file_copy.py", line 21, in

sftp.put('/home/e100075/python/ss.txt', '/home/developers/screenshots/ss.txt')

File "/usr/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 565, in put

fr = self.file(remotepath, 'wb')

File "/usr/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 245, in open

t, msg = self._request(CMD_OPEN, filename, imode, attrblock)

File "/usr/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 635, in _request

return self._read_response(num)

File "/usr/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 682, in _read_response

self._convert_status(msg)

File "/usr/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 708, in _convert_status

raise IOError(errno.ENOENT, text)

IOError: [Errno 2] No such file

如果你知道答案。请告诉我

谢谢你的阅读。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值