使用Python从windows sftp到unix
我正在尝试将文件从我的 Windows 笔记本电脑 sftp 到 Unix 盒子(Juniper 路由器)。
我写了一个小脚本,但它说我的远程路径错误。我知道我可能需要添加一些奇特的东西,以便 Windows 可以翻译 nix 目录,但我在 Google 上找不到它:(
这是脚本:
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()
我收到错误:
WindowsError:[错误3]系统找不到指定的路径:'/balls/test.txt'
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'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信您已经交换了本地和远程路径。尝试:
有关详细信息,请参阅API。
I believe you've swapped the local and remote paths. Try:
For some details, see the API.
如果远程主机上的根目录中没有名为 balls 的目录,您也可能会遇到问题。
You may also have a problem if there isn't a directory named balls off your root directory on the remote host.