Net/sftp 1.10 errors

I recently downloaded net/ssh 1.0.7 and net/sftp 1.1.0. But I get
problems with ruby 1.8.2, 1.8.3 on
either windows, debian or ubuntu boxes.

require ‘rubygems’
require ‘net/sftp’

sftp_sess = Net::SFTP.start ‘host’, ‘username’, ‘password’
sftp_sess.put_file ‘/home/uberriffic/test.txt’,
‘/home/uberriffic/remote_test.txt’
NoMethodError: private method open' called for #<Net::SFTP::Protocol::Driver:0xb7863790> from /usr/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/sftp/protocol/driver.rb:201:inmethod_missing’
from
/usr/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/sftp/operations/open.rb:27:in
perform' from /usr/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/sftp/operations/abstract.rb:64:inexecute’
from
/usr/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/sftp/session.rb:253:in
method_missing' from /usr/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/sftp/session.rb:177:inopen_handle’
from
/usr/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/sftp/session.rb:203:in
`put_file’
from (irb):4
from :0

Do I need ruby 1.8.4? Thanks

Zach

On Feb 14, 2006, at 6:03 AM, zdennis wrote:

NoMethodError: private method open' called for sftp/session.rb:177:inopen_handle’
from /usr/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/
sftp/session.rb:203:in `put_file’
from (irb):4
from :0

Do I need ruby 1.8.4? Thanks

Zach

Zach,

Thanks for this report. I’m not sure yet what’s going wrong here, but
I can duplicate the error on my machine and I’ll look into it.

  • Jamis

On Feb 14, 2006, at 6:03 AM, zdennis wrote:

NoMethodError: private method open' called for sftp/session.rb:177:inopen_handle’
from /usr/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/
sftp/session.rb:203:in `put_file’
from (irb):4
from :0

Here are two workarounds:

First, you can use a block to Net::SFTP.start:

Net::SFTP.start(…) do |sess|
sess.put_file(…)
end

Or, if you can’t use the block format for whatever reason, be sure to
call #connect after calling start:

sess = Net::SFTP.start(…)
sess.connect
sess.put_file(…)

Not sure why that connect isn’t being called automatically, but I’ll
look into it.

  • Jamis

Jamis B. wrote:

sftp_sess.put_file ‘/home/uberriffic/test.txt’, ‘/home/uberriffic/
sftp/session.rb:253:in `method_missing’
First, you can use a block to Net::SFTP.start:
sess.put_file(…)

Not sure why that connect isn’t being called automatically, but I’ll
look into it.

Thank you very much Jamis!

Zach

Jamis B. wrote:

Not sure why that connect isn’t being called automatically, but I’ll
look into it.

  • Jamis

A bit off topic for this thread, but is Net::SFTP the best way to do
things like user-uploads to a rails app to a remote host like
Strongspace?

Jake