Ruby on rails ruby sftp错误
我正在尝试使用ruby将文件上传到我的sftp,我可以使用ssh,一切都很好,但我的脚本失败了……这是我的小脚本Ruby on rails ruby sftp错误,ruby-on-rails,ruby,scripting,sftp,Ruby On Rails,Ruby,Scripting,Sftp,我正在尝试使用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
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
但我总是犯这个错误
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)
任何关于我做错了什么的想法我相信在使用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
在文档中,示例使用文件的远程路径,而不仅仅是目录
似乎目录的上载会首先尝试mkdir该目标目录 如果目标目录已经存在,那么mkdir将按照原始目录中给出的示例失败。我仍然在寻找一种使用内置上传目录的方法——同时,我的程序遍历本地目录,并分别上传每个文件