Python Forum
no such file or directory in SFTP
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
no such file or directory in SFTP
#1
I am using sftp.put() to upload files into SFTP server.But i am following error
Error:
No such file or directory
This is my present folder structure:

     
 - Django_Project
       -djangoapp
           -scripts
                -sftpconnection.py
       -Django_Project
       -xmloutput
              -output.xml
In the sftpconnection.py i have the following code to upload the file to sftp server

def upload_to_sftp(request):
    cnOpts = pysftp.CnOpts()
    cnOpts.hostkeys = None
    sftp = pysftp.Connection(host="10.23.43.56", username="xxxxx", password="xxxx", port=22,cnopts=cnOpts)
    
    sftp.put(localpath='../../xmloutput/Output.xml', remotepath=sftp.cwd("/srv/sftp/inbox"))
    sftp.close()
any inputs ?
Reply
#2
Please, always show entire unaltered error traceback as it contains valuable debugging information.
Reply
#3
Relative paths do not work.
localpath='../../xmloutput/Output.xml'
This is also wrong:
remotepath=sftp.cwd("/srv/sftp/inbox")
This works because cwd returns None and the default argument for remotepath is a None.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Using pyinstaller with .ui GUI files - No such file or directory error diver999 3 3,076 Jun-27-2023, 01:17 PM
Last Post: diver999
  Extract file only (without a directory it is in) from ZIPIP tester_V 1 928 Jan-23-2023, 04:56 AM
Last Post: deanhystad
Thumbs Up Need to compare the Excel file name with a directory text file. veeran1991 1 1,064 Dec-15-2022, 04:32 PM
Last Post: Larz60+
Photo Making Zip file of a file and Directory Nasir 2 984 Oct-07-2022, 02:01 PM
Last Post: Nasir
  Failed to execute child process (No such file or directory) uriel 1 1,616 Sep-15-2022, 03:48 PM
Last Post: Gribouillis
  file transfer via python SFTP SCP mg24 3 2,875 Sep-15-2022, 04:20 AM
Last Post: mg24
  Need Help: FileNotFoundError:[Errno 2] No such file or directory python202209 5 2,523 Sep-12-2022, 04:50 AM
Last Post: python202209
  importing functions from a separate python file in a separate directory Scordomaniac 3 1,330 May-17-2022, 07:49 AM
Last Post: Pedroski55
  How to read python shortcut target profile directory of Chrome Ink file sunny9495 1 1,617 Apr-12-2022, 06:12 PM
Last Post: sunny9495
Question Help to find the largest int number in a file directory SalzmannNicholas 1 1,586 Jan-13-2022, 05:22 PM
Last Post: ndc85430

Forum Jump:

User Panel Messages

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