我正在尝试使用ruby将文件上传到我的sftp,我可以使用ssh,一切正常,但我的脚本失败了....here是我的小脚本
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)你知道我做错了什么吗
发布于 2011-08-25 00:29:35
我相信在使用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在文档中,示例使用文件的远程路径,而不仅仅是目录。
http://net-ssh.github.com/sftp/v2/api/classes/Net/SFTP/Operations/Upload.html
发布于 2012-08-26 03:12:03
目录的上载似乎会先尝试mkdir该目标目录。
如果目标目录已经存在,mkdir将按照原始目录中给出的示例失败。我仍然在寻找一种使用内置上传目录的方法--同时,我的程序遍历本地目录,并单独上传每个文件。
https://stackoverflow.com/questions/7178895
复制相似问题