0

I have a program which transfers files to different endpoints. Only one endpoint in particular fails on this conn.put():

try:
  conn.put(fileToPush, pushedFile)
except IOError as ioe:
    self.logPush('IOError: {} - Exiting...'.format(str(ioe)))

The output:

IOError: [Errno 2] No such file - Exiting...

But I sftp to the destination from the command line and I do an "ls -ltr" and one of the two files I'm trying to push is there.

The file's size is 900117 bytes. Then on sftp, I can also see the file size as 900117 bytes.

How does it transfer 1 whole file and still run into an IOError?

dreami
  • 31
  • 7
  • 1
    What about the source and destination paths for both of those files? It sounds like the second one wasn't right. You could `print(repr(fileToPush), repr(pushedFile))` to see. Do these go to the same remote directory? Does the server move files after they've been dropped in the directory? – tdelaney Oct 15 '21 at 00:57
  • always put full error message (starting at word "Traceback") in question (not comment) as text (not screenshot, not link to external portal). There are other useful information. – furas Oct 15 '21 at 03:37
  • first you should use `print()` to see values in variables. You could also check current working directory `os.getcwd()` or check what you have in folder `os.listdir(...)` – furas Oct 15 '21 at 03:42
  • 1
    See [Python pysftp.put raises "No such file" exception although file is uploaded](https://stackoverflow.com/q/49718668/850848) – If this does not help, post a full exception callstack. + Example of path syntaxes + Log file of any commandline/GUI SFTP client that can upload the same file to the same target path using the same credentials. – Martin Prikryl Oct 15 '21 at 05:03
  • Thank you, it was actually the same issue as the issue you linked me too. I just thought that it was different because I could see the files with an ls -ltr when I was connectin from sftp from cmd line but what I was seeing wasn't a real life listing. – dreami Oct 15 '21 at 23:07

0 Answers0