Ruby sftp error

I am trying to use ruby ​​to upload a file to sftp and I can ssh and everything is fine, but my script is not working .... here is my little script

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 

but i keep getting this error

  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) 

Any ideas what I'm doing wrong

+8
ruby scripting ruby-on-rails sftp
source share
2 answers

I believe that when using sftp, you must specify the target file .

 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 

In the documentation, examples use a remote file path, not just a directory.

http://net-ssh.github.com/sftp/v2/api/classes/Net/SFTP/Operations/Upload.html

+15
source share

It seems that loading the directory tries to start mkdir in this destination directory first.

If this destination directory already exists, mkdir does not work according to the example specified in the original. I'm still looking for a way to use inline directory loading. Meanwhile, my program goes to the local directory and downloads each file individually.

+1
source share

All Articles