Net:sftp 2.0.5 upload! does not work

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:

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:innew’
upload' from C:/ruby/lib/ruby/gems/1.8/gems/net-sftp-2.0.5/lib/net/sftp/session.rb:103:inupload!’

Here are the related lines of code:

sftp = Net::SFTP.start('somehost', 'someuserid', :password =>
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…

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 “”) 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. :slight_smile:

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.