'put' in SFTP using Paramiko

前端 未结 2 980
借酒劲吻你
借酒劲吻你 2020-12-15 16:11

I\'ve installed and written the following Paramiko which is unable to put the file. It is easily able to \'get\' a file and execute ls commands on it.



        
相关标签:
2条回答
  • 2020-12-15 16:50

    This also occurs in 2.0.2 when you try to sftp.mkdir('/exists'):

    Traceback (most recent call last):
      ...
      File "/usr/local/lib/python2.7/site-packages/paramiko/sftp_client.py", line 380, in mkdir
        self._request(CMD_MKDIR, path, attr)
      File "/usr/local/lib/python2.7/site-packages/paramiko/sftp_client.py", line 730, in _request
        return self._read_response(num)
      File "/usr/local/lib/python2.7/site-packages/paramiko/sftp_client.py", line 781, in _read_response
        self._convert_status(msg)
      File "/usr/local/lib/python2.7/site-packages/paramiko/sftp_client.py", line 811, in _convert_status
        raise IOError(text)
    IOError: Failure
    

    This was my Python 2.7.9 fix:

    try:
        sftp.mkdir(remote_dir)
    except IOError:
        logging.debug('%s already exists.', remote_dir)
    
    0 讨论(0)
  • 2020-12-15 17:07

    The solution seemed very funny to me!

    source= '/Unzip.sh' 
    destination ='/var/mpx/www/http/Unzip.sh'
    

    Just modified the destination path to include the file name as well. Didn't expect some error like this coming from a Python package.

    0 讨论(0)
提交回复
热议问题