Python Forum
Paramiko SSH "put", destination name
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Paramiko SSH "put", destination name
#1
Hello all, I am having difficulties understanding paramiko's behaviour, when it comes to sending files over SSH. I have this function:

def SSH_send_file(file, host, username, password, path):   
   s = paramiko.SSHClient()
   s.set_missing_host_key_policy(paramiko.AutoAddPolicy())
   s.connect(host, 22, username, password)
   sftp = s.open_sftp()
   sftp.put(file, path)
   s.close()
For example, you would call it like:
SSH_send_file("file_to_send.txt", "10.20.30.40", "user", "secret", "/tmp")

Until now, it worked fine using it like in the example above. But now (in same program) there was an occassion when this error happened:
Error:
  File "\lib\site-packages\paramiko\sftp_client.py", line 811, in _convert_status     raise IOError(text) OSError: Failure
After some Googling I found that solution is to pass complete destination name to function, which means the file name included, like this:
SSH_send_file("file_to_send.txt", "10.20.30.40", "user", "secret", "/tmp/file_to_send.txt")

Why did this function "change behaviour", so I had to use it differently in one case, as opposed to previous uses? Can I avoid/predict it in future?
Thank you! JC
Reply


Messages In This Thread
Paramiko SSH "put", destination name - by j.crater - Mar-23-2017, 09:39 AM
RE: Paramiko SSH "put", destination name - by buran - Mar-23-2017, 09:52 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python move specific files from source to destination including duplicates mg24 3 1,189 Jan-21-2023, 04:21 AM
Last Post: deanhystad
  Shutil move if file exists in destination Friend 2 6,966 Feb-02-2020, 01:45 PM
Last Post: Friend
  How to specify the destination folder SriMekala 1 3,336 May-21-2019, 11:45 AM
Last Post: DeaD_EyE
  get destination path from item from QlistWidget faithcure 3 3,369 Jul-25-2018, 09:37 PM
Last Post: nilamo
  copy files from one destination to another by reading filename from csv Prince_Bhatia 3 7,781 Feb-27-2018, 10:56 AM
Last Post: Prince_Bhatia

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020