Mat*_*iby 8 ruby scripting sftp ruby-on-rails
我正在尝试使用ruby将文件上传到我的sftp并且我可以ssh并且一切都很好但是我的脚本失败了....这是我的小脚本
require 'rubygems'
require 'net/sftp'
Net::SFTP.start('50.5.54.77', 'root', :password => 'PASSWORD') do |sftp|
# upload a file or directory to the remote host
sftp.upload!("/Users/tamer/sites/sandbox/move_me.txt", "/home")
end
Run Code Online (Sandbox Code Playgroud)
但我一直收到这个错误
ruby sftp.rb
/Library/Ruby/Gems/1.8/gems/net-sftp-2.0.5/lib/net/sftp/operations/upload.rb:313:in `on_open':
Net::SFTP::StatusException open /srv (4, "failure") (Net::SFTP::StatusException)
Run Code Online (Sandbox Code Playgroud)
我有什么不妥的想法
Gaz*_*ler 15
我相信在使用sftp时,必须指定目标文件.
Net::SFTP.start('50.5.54.77', 'root', :password => 'PASSWORD') do |sftp|
# upload a file or directory to the remote host
sftp.upload!("/Users/tamer/sites/sandbox/move_me.txt", "/home/move_me.txt")
end
Run Code Online (Sandbox Code Playgroud)
在文档中,示例使用远程路径来存档,而不仅仅是目录.
http://net-ssh.github.com/sftp/v2/api/classes/Net/SFTP/Operations/Upload.html
| 归档时间: |
|
| 查看次数: |
7448 次 |
| 最近记录: |