4

I am trying to sftp a file from my Windows laptop to a Unix box (Juniper router).

I wrote a small script but it says I have the remote path wrong. i know there is probably something fancy I need to add so windows can translate the nix directory but I can't find it on Google :(

Here is the script:

import paramiko
host = "192.168.1.87"
port = 22
transport = paramiko.Transport((host, port)) 
password = "juniper123"
username = "root"
transport.connect(username = username, password = password)
sftp = paramiko.SFTPClient.from_transport(transport)
filepath = '/balls/test.txt'
localpath = 'C:\Users\python1\test.txt'
sftp.put(filepath, localpath)
sftp.close()
transport.close()

I get the error:

WindowsError: [Error 3] The system cannot find the path specified: '/balls/test.txt'

2 Answers 2

5
sftp.put(filepath, localpath)

I believe you've swapped the local and remote paths. Try:

sftp.put(localpath, filepath)

For some details, see the API.

Sign up to request clarification or add additional context in comments.

Comments

1

You may also have a problem if there isn't a directory named balls off your root directory on the remote host.

2 Comments

there is :) it's our test dir.
Cool. I've personally tried to upload to a nonexistent directory during a rigged demo. Oops. ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.