Python Forum

Full Version: no such file or directory in SFTP
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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 ?
Please, always show entire unaltered error traceback as it contains valuable debugging information.
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.