Hello all, I am having difficulties understanding paramiko's behaviour, when it comes to sending files over SSH. I have this function:
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:
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
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