net:sftp 2.0.5 upload! does not work

  • Thread starter Peter (Guo) Pei
  • Start date
P

Peter (Guo) Pei

I tried to upload files from a windows box to a linux box, and I used
net:sftp 2.0.5. However I got the following error message:

C:/ruby/lib/ruby/gems/1.8/gems/net-sftp-2.0.5/lib/net/sftp/operations/upload.rb:168:in
`initialize': expected a file to upload (ArgumentError)
from
C:/ruby/lib/ruby/gems/1.8/gems/net-sftp-2.0.5/lib/net/sftp/session.rb:98:in
`new'
from
C:/ruby/lib/ruby/gems/1.8/gems/net-sftp-2.0.5/lib/net/sftp/session.rb:98:in
`upload'
from
C:/ruby/lib/ruby/gems/1.8/gems/net-sftp-2.0.5/lib/net/sftp/session.rb:103:in
`upload!'

Here are the related lines of code:
Code:
sftp = Net::SFTP.start('somehost', 'someuserid', :password =>
'somepassword')
sftp.upload!("c:\\dba\\1.0.29_QA\\" + windows_path, "./dba/" + line)

I know the file exists, and I tried different ways of specifying the
path, with slash and backslash, with full path and particial path... but
none of those worked.

I suspect net:sftp 2.0.5 is broken...
 
A

Alex Stahl

In my experience, more often than not the gem isn't broken - it's your
use. (As I've witnessed through a lack of response to some of my posts
stating exactly that).

And while I can't answer your question directly, I would suggest that
you are likely doing it wrong, rather than sftp being broken on such a
simple test case.

Have you exhausted your troubleshooting? Are you sure? Have you tried
other file access statements (such as "File.open") to confirm your path
statements? A step earlier, have you confirmed valid instantiation of
your object? For instance, by calling a different method on 'sftp'?
Are you beyond 100% positive that your value in 'windows_path' is
correct? Maybe it has a newline tacked on the end?

Of course, as these types of problems usually go, you've hopefully
already solved this. :)
 
P

Peter (Guo) Pei

Figured out...

I got those file names from a text file by calling gets, and before I
can pass them to "upload!", I need to call strip! first.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top