Hi all, I am having following code in ruby require ''net/ssh'' require ''net/sftp'' begin Net::SSH.start (''132.147.161.159'',:password=>''k'',:port=>1234,:username=>''k'') do |ssh| ssh.sftp.connect do |sftp| Dir.foreach(''.'') do |file| puts file end end end rescue Exception=> Ex puts Ex.message end After executing the above code it is giving me following error Bad file descriptor - connect(2) username, password, and ipaddress are fine What I want is to take data from remote machine to server. Please Help me out. Thanks and Regards, Shri --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Tue, Apr 7, 2009 at 10:27 PM, Shripad <shripad.joshi.s-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi all, > > I am having following code in ruby > > require ''net/ssh'' > require ''net/sftp'' > begin > Net::SSH.start > (''132.147.161.159'',:password=>''k'',:port=>1234,:username=>''k'') do |ssh| > ssh.sftp.connect do |sftp| > Dir.foreach(''.'') do |file| > puts file > end > end > end > rescue Exception=> Ex > puts Ex.message > end > > After executing the above code it is giving me following error > > Bad file descriptor - connect(2) > > username, password, and ipaddress are fine > > What I want is to take data from remote machine to server. > > Please Help me out. > > > Thanks and Regards, > ShriWhat are you wanting to do? SFTP or SSH? From the code, it appears that you''re trying to move a file from point A to B. Thus, here''s a brief outline of the things that you can do with SFTP: require ''net/sftp'' Net::SFTP.start(''host'', ''username'', :password => ''password'') do |sftp| # upload a file or directory to the remote host sftp.upload!("/path/to/local", "/path/to/remote") # download a file or directory from the remote host sftp.download!("/path/to/remote", "/path/to/local") # grab data off the remote host directly to a buffer data = sftp.download!("/path/to/remote") # open and write to a pseudo-IO for a remote file sftp.file.open("/path/to/remote", "w") do |f| f.puts "Hello, world!\n" end # open and read from a pseudo-IO for a remote file sftp.file.open("/path/to/remote", "r") do |f| puts f.gets end # create a directory sftp.mkdir! "/path/to/directory" # list the entries in a directory sftp.dir.foreach("/path/to/directory") do |entry| puts entry.longname end end Good luck, -Conrad> > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, Thanks Conrad for ur urgent reply What I want to do is just pickup the images from machine A to machine B. I did what you say but I am getting error as follows E:/InstantRails/ruby/lib/ruby/gems/1.8/gems/net-sftp-2.0.2/lib/net/ sftp.rb:43:in `start'': undefined method `shutdown!'' for nil:NilClass (NoMethodError) from SSHTransfer.rb:8 what I write is this sftp=Net::SFTP.start(''132.147.161.159'', ''k'',:password => ''k'') Thanks and Regards On Apr 8, 11:24 am, Conrad Taylor <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Tue, Apr 7, 2009 at 10:27 PM, Shripad <shripad.josh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi all, > > > I am having following code in ruby > > > require ''net/ssh'' > > require ''net/sftp'' > > begin > > Net::SSH.start > > (''132.147.161.159'',:password=>''k'',:port=>1234,:username=>''k'') do |ssh| > > ssh.sftp.connect do |sftp| > > Dir.foreach(''.'') do |file| > > puts file > > end > > end > > end > > rescue Exception=> Ex > > puts Ex.message > > end > > > After executing the above code it is giving me following error > > > Bad file descriptor - connect(2) > > > username, password, and ipaddress are fine > > > What I want is to take data from remote machine to server. > > > Please Help me out. > > > Thanks and Regards, > > Shri > > What are you wanting to do? SFTP or SSH? From the code, > it appears that you''re trying to move a file from point A to B. > Thus, here''s a brief outline of the things that you can do with > SFTP: > > require ''net/sftp'' > > Net::SFTP.start(''host'', ''username'', :password => ''password'') do |sftp| > # upload a file or directory to the remote host > sftp.upload!("/path/to/local", "/path/to/remote") > > # download a file or directory from the remote host > sftp.download!("/path/to/remote", "/path/to/local") > > # grab data off the remote host directly to a buffer > data = sftp.download!("/path/to/remote") > > # open and write to a pseudo-IO for a remote file > sftp.file.open("/path/to/remote", "w") do |f| > f.puts "Hello, world!\n" > end > > # open and read from a pseudo-IO for a remote file > sftp.file.open("/path/to/remote", "r") do |f| > puts f.gets > end > > # create a directory > sftp.mkdir! "/path/to/directory" > > # list the entries in a directory > sftp.dir.foreach("/path/to/directory") do |entry| > puts entry.longname > end > end > > Good luck, > > -Conrad > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Wed, Apr 8, 2009 at 12:08 AM, Shripad <shripad.joshi.s-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, > Thanks Conrad for ur urgent reply > > What I want to do is just pickup the images from machine A to machine > B. > > I did what you say but I am getting error as follows > > E:/InstantRails/ruby/lib/ruby/gems/1.8/gems/net-sftp-2.0.2/lib/net/ > sftp.rb:43:in > `start'': undefined method `shutdown!'' for nil:NilClass > (NoMethodError) > from SSHTransfer.rb:8 > > what I write is this > sftp=Net::SFTP.start(''132.147.161.159'', ''k'',:password => ''k'') > > Thanks and Regards > > On Apr 8, 11:24 am, Conrad Taylor <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > On Tue, Apr 7, 2009 at 10:27 PM, Shripad <shripad.josh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > > > Hi all, > > > > > I am having following code in ruby > > > > > require ''net/ssh'' > > > require ''net/sftp'' > > > begin > > > Net::SSH.start > > > (''132.147.161.159'',:password=>''k'',:port=>1234,:username=>''k'') do |ssh| > > > ssh.sftp.connect do |sftp| > > > Dir.foreach(''.'') do |file| > > > puts file > > > end > > > end > > > end > > > rescue Exception=> Ex > > > puts Ex.message > > > end > > > > > After executing the above code it is giving me following error > > > > > Bad file descriptor - connect(2) > > > > > username, password, and ipaddress are fine > > > > > What I want is to take data from remote machine to server. > > > > > Please Help me out. > > > > > Thanks and Regards, > > > Shri > > > > What are you wanting to do? SFTP or SSH? From the code, > > it appears that you''re trying to move a file from point A to B. > > Thus, here''s a brief outline of the things that you can do with > > SFTP: > > > > require ''net/sftp'' > > > > Net::SFTP.start(''host'', ''username'', :password => ''password'') do |sftp| > > # upload a file or directory to the remote host > > sftp.upload!("/path/to/local", "/path/to/remote") > > > > # download a file or directory from the remote host > > sftp.download!("/path/to/remote", "/path/to/local") > > > > # grab data off the remote host directly to a buffer > > data = sftp.download!("/path/to/remote") > > > > # open and write to a pseudo-IO for a remote file > > sftp.file.open("/path/to/remote", "w") do |f| > > f.puts "Hello, world!\n" > > end > > > > # open and read from a pseudo-IO for a remote file > > sftp.file.open("/path/to/remote", "r") do |f| > > puts f.gets > > end > > > > # create a directory > > sftp.mkdir! "/path/to/directory" > > > > # list the entries in a directory > > sftp.dir.foreach("/path/to/directory") do |entry| > > puts entry.longname > > end > > end > > > > Good luck, > > > > -Conrad > > > > >Can you upgrade the gem and retrying what you did before? You can upgrade by doing the following: sudo gem update -Conrad --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, I updated the gem. but still it is showing me the same error. I am using windows, is that a problem for SFTP? IS OpenSSH require for SFTP to connect to remote machine? Is there any other way to do this? Thanks and Regards, Shripad On Apr 8, 12:58 pm, Conrad Taylor <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Wed, Apr 8, 2009 at 12:08 AM, Shripad <shripad.josh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi, > > Thanks Conrad for ur urgent reply > > > What I want to do is just pickup the images from machine A to machine > > B. > > > I did what you say but I am getting error as follows > > > E:/InstantRails/ruby/lib/ruby/gems/1.8/gems/net-sftp-2.0.2/lib/net/ > > sftp.rb:43:in > > `start'': undefined method `shutdown!'' for nil:NilClass > > (NoMethodError) > > from SSHTransfer.rb:8 > > > what I write is this > > sftp=Net::SFTP.start(''132.147.161.159'', ''k'',:password => ''k'') > > > Thanks and Regards > > > On Apr 8, 11:24 am, Conrad Taylor <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On Tue, Apr 7, 2009 at 10:27 PM, Shripad <shripad.josh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > > > Hi all, > > > > > I am having following code in ruby > > > > > require ''net/ssh'' > > > > require ''net/sftp'' > > > > begin > > > > Net::SSH.start > > > > (''132.147.161.159'',:password=>''k'',:port=>1234,:username=>''k'') do |ssh| > > > > ssh.sftp.connect do |sftp| > > > > Dir.foreach(''.'') do |file| > > > > puts file > > > > end > > > > end > > > > end > > > > rescue Exception=> Ex > > > > puts Ex.message > > > > end > > > > > After executing the above code it is giving me following error > > > > > Bad file descriptor - connect(2) > > > > > username, password, and ipaddress are fine > > > > > What I want is to take data from remote machine to server. > > > > > Please Help me out. > > > > > Thanks and Regards, > > > > Shri > > > > What are you wanting to do? SFTP or SSH? From the code, > > > it appears that you''re trying to move a file from point A to B. > > > Thus, here''s a brief outline of the things that you can do with > > > SFTP: > > > > require ''net/sftp'' > > > > Net::SFTP.start(''host'', ''username'', :password => ''password'') do |sftp| > > > # upload a file or directory to the remote host > > > sftp.upload!("/path/to/local", "/path/to/remote") > > > > # download a file or directory from the remote host > > > sftp.download!("/path/to/remote", "/path/to/local") > > > > # grab data off the remote host directly to a buffer > > > data = sftp.download!("/path/to/remote") > > > > # open and write to a pseudo-IO for a remote file > > > sftp.file.open("/path/to/remote", "w") do |f| > > > f.puts "Hello, world!\n" > > > end > > > > # open and read from a pseudo-IO for a remote file > > > sftp.file.open("/path/to/remote", "r") do |f| > > > puts f.gets > > > end > > > > # create a directory > > > sftp.mkdir! "/path/to/directory" > > > > # list the entries in a directory > > > sftp.dir.foreach("/path/to/directory") do |entry| > > > puts entry.longname > > > end > > > end > > > > Good luck, > > > > -Conrad > > Can you upgrade the gem and retrying what you > did before? You can upgrade by doing the following: > > sudo gem update > > -Conrad--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Wed, Apr 8, 2009 at 1:09 AM, Shripad <shripad.joshi.s-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, > > I updated the gem. > but still it is showing me the same error. > I am using windows, is that a problem for SFTP? > IS OpenSSH require for SFTP to connect to remote machine? > Is there any other way to do this? > > Thanks and Regards, > Shripad >Shripad, I''m not sure of the state of Capistrano on Windows. I''m sure that you''ll need the OpenSSH library installed on your system. Thus, it may be easier to install Cygwin and install OpenSSH from there. Otherwise, you can switch to Linux or Mac OS X or other Unix variant. Good luck, -Conrad> > On Apr 8, 12:58 pm, Conrad Taylor <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > On Wed, Apr 8, 2009 at 12:08 AM, Shripad <shripad.josh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > > > Hi, > > > Thanks Conrad for ur urgent reply > > > > > What I want to do is just pickup the images from machine A to machine > > > B. > > > > > I did what you say but I am getting error as follows > > > > > E:/InstantRails/ruby/lib/ruby/gems/1.8/gems/net-sftp-2.0.2/lib/net/ > > > sftp.rb:43:in > > > `start'': undefined method `shutdown!'' for nil:NilClass > > > (NoMethodError) > > > from SSHTransfer.rb:8 > > > > > what I write is this > > > sftp=Net::SFTP.start(''132.147.161.159'', ''k'',:password => ''k'') > > > > > Thanks and Regards > > > > > On Apr 8, 11:24 am, Conrad Taylor <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > On Tue, Apr 7, 2009 at 10:27 PM, Shripad <shripad.josh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > wrote: > > > > > > > Hi all, > > > > > > > I am having following code in ruby > > > > > > > require ''net/ssh'' > > > > > require ''net/sftp'' > > > > > begin > > > > > Net::SSH.start > > > > > (''132.147.161.159'',:password=>''k'',:port=>1234,:username=>''k'') do > |ssh| > > > > > ssh.sftp.connect do |sftp| > > > > > Dir.foreach(''.'') do |file| > > > > > puts file > > > > > end > > > > > end > > > > > end > > > > > rescue Exception=> Ex > > > > > puts Ex.message > > > > > end > > > > > > > After executing the above code it is giving me following error > > > > > > > Bad file descriptor - connect(2) > > > > > > > username, password, and ipaddress are fine > > > > > > > What I want is to take data from remote machine to server. > > > > > > > Please Help me out. > > > > > > > Thanks and Regards, > > > > > Shri > > > > > > What are you wanting to do? SFTP or SSH? From the code, > > > > it appears that you''re trying to move a file from point A to B. > > > > Thus, here''s a brief outline of the things that you can do with > > > > SFTP: > > > > > > require ''net/sftp'' > > > > > > Net::SFTP.start(''host'', ''username'', :password => ''password'') do > |sftp| > > > > # upload a file or directory to the remote host > > > > sftp.upload!("/path/to/local", "/path/to/remote") > > > > > > # download a file or directory from the remote host > > > > sftp.download!("/path/to/remote", "/path/to/local") > > > > > > # grab data off the remote host directly to a buffer > > > > data = sftp.download!("/path/to/remote") > > > > > > # open and write to a pseudo-IO for a remote file > > > > sftp.file.open("/path/to/remote", "w") do |f| > > > > f.puts "Hello, world!\n" > > > > end > > > > > > # open and read from a pseudo-IO for a remote file > > > > sftp.file.open("/path/to/remote", "r") do |f| > > > > puts f.gets > > > > end > > > > > > # create a directory > > > > sftp.mkdir! "/path/to/directory" > > > > > > # list the entries in a directory > > > > sftp.dir.foreach("/path/to/directory") do |entry| > > > > puts entry.longname > > > > end > > > > end > > > > > > Good luck, > > > > > > -Conrad > > > > Can you upgrade the gem and retrying what you > > did before? You can upgrade by doing the following: > > > > sudo gem update > > > > -Conrad > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
No, The same error appears on my Power Mac OSX 10.5.7 $ cat data-sync.rb require ''rubygems'' require ''net/sftp'' host, user, passwd = ''10.50.33.100'', ''login'', ''pass'' path = ''/var/cms/storenew/workspace/live/data'' Net::SFTP.start(host, user, passwd) do |sftp| sftp.file.open(path, ''r'') do |f| puts f.gets() end end Error for Ruby 1.8.6 EE: $ ruby -v ruby 1.8.6 (2008-08-08 patchlevel 286) [i686-darwin9.6.0] $ ruby data-sync.rb /opt/ruby-enterprise-1.8.6-20090201/lib/ruby/gems/1.8/gems/net- sftp-2.0.2/lib/net/sftp.rb:43:in `start'': undefined method `shutdown!'' for nil:NilClass (NoMethodError) from data-sync.rb:7 And the same for Ruby 1.9: $ ruby1.9 -v ruby 1.9.1 (2008-12-30 patchlevel-0 revision 21203) [i386-darwin9] $ ruby1.9 data-sync.rb /opt/local/lib/ruby1.9/gems/1.9.1/gems/net-sftp-2.0.2/lib/net/sftp.rb: 43:in `rescue in start'': undefined method `shutdown!'' for nil:NilClass (NoMethodError) from /opt/local/lib/ruby1.9/gems/1.9.1/gems/net-sftp-2.0.2/lib/net/ sftp.rb:31:in `start'' from data-sync.rb:7:in `<main>'' On Apr 8, 11:30 am, Conrad Taylor <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Wed, Apr 8, 2009 at 1:09 AM, Shripad <shripad.josh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi, > > > I updated the gem. > > but still it is showing me the same error. > > I am using windows, is that a problem for SFTP? > > IS OpenSSH require for SFTP to connect to remote machine? > > Is there any other way to do this? > > > Thanks and Regards, > > Shripad > > Shripad, I''m not sure of the state of Capistrano on Windows. I''m sure that > you''ll need the OpenSSH library installed on your system. Thus, it may be > easier to install Cygwin and install OpenSSH from there. Otherwise, you can > switch to Linux or Mac OS X or other Unix variant. > > Good luck, > > -Conrad > > > > > On Apr 8, 12:58 pm, Conrad Taylor <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On Wed, Apr 8, 2009 at 12:08 AM, Shripad <shripad.josh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > > > Hi, > > > > Thanks Conrad for ur urgent reply > > > > > What I want to do is just pickup the images from machine A to machine > > > > B. > > > > > I did what you say but I am getting error as follows > > > > > E:/InstantRails/ruby/lib/ruby/gems/1.8/gems/net-sftp-2.0.2/lib/net/ > > > > sftp.rb:43:in > > > > `start'': undefined method `shutdown!'' for nil:NilClass > > > > (NoMethodError) > > > > from SSHTransfer.rb:8 > > > > > what I write is this > > > > sftp=Net::SFTP.start(''132.147.161.159'', ''k'',:password => ''k'') > > > > > Thanks and Regards > > > > > On Apr 8, 11:24 am, Conrad Taylor <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > On Tue, Apr 7, 2009 at 10:27 PM, Shripad <shripad.josh...@gmail.com> > > > > wrote: > > > > > > > Hi all, > > > > > > > I am having following code in ruby > > > > > > > require ''net/ssh'' > > > > > > require ''net/sftp'' > > > > > > begin > > > > > > Net::SSH.start > > > > > > (''132.147.161.159'',:password=>''k'',:port=>1234,:username=>''k'') do > > |ssh| > > > > > > ssh.sftp.connect do |sftp| > > > > > > Dir.foreach(''.'') do |file| > > > > > > puts file > > > > > > end > > > > > > end > > > > > > end > > > > > > rescue Exception=> Ex > > > > > > puts Ex.message > > > > > > end > > > > > > > After executing the above code it is giving me following error > > > > > > > Bad file descriptor - connect(2) > > > > > > > username, password, and ipaddress are fine > > > > > > > What I want is to take data from remote machine to server. > > > > > > > Please Help me out. > > > > > > > Thanks and Regards, > > > > > > Shri > > > > > > What are you wanting to do? SFTP or SSH? From the code, > > > > > it appears that you''re trying to move a file from point A to B. > > > > > Thus, here''s a brief outline of the things that you can do with > > > > > SFTP: > > > > > > require ''net/sftp'' > > > > > > Net::SFTP.start(''host'', ''username'', :password => ''password'') do > > |sftp| > > > > > # upload a file or directory to the remote host > > > > > sftp.upload!("/path/to/local", "/path/to/remote") > > > > > > # download a file or directory from the remote host > > > > > sftp.download!("/path/to/remote", "/path/to/local") > > > > > > # grab data off the remote host directly to a buffer > > > > > data = sftp.download!("/path/to/remote") > > > > > > # open and write to a pseudo-IO for a remote file > > > > > sftp.file.open("/path/to/remote", "w") do |f| > > > > > f.puts "Hello, world!\n" > > > > > end > > > > > > # open and read from a pseudo-IO for a remote file > > > > > sftp.file.open("/path/to/remote", "r") do |f| > > > > > puts f.gets > > > > > end > > > > > > # create a directory > > > > > sftp.mkdir! "/path/to/directory" > > > > > > # list the entries in a directory > > > > > sftp.dir.foreach("/path/to/directory") do |entry| > > > > > puts entry.longname > > > > > end > > > > > end > > > > > > Good luck, > > > > > > -Conrad > > > > Can you upgrade the gem and retrying what you > > > did before? You can upgrade by doing the following: > > > > sudo gem update > > > > -Conrad
Ech we were fooled by misleading example from http://net-ssh.rubyforge.org/sftp/v1/faq.html. The correct API is at http://net-ssh.rubyforge.org/sftp/v2/api/index.html. So instead of sftp = Net::SFTP.start(''host'', ''username'', ''password'') it should be: sftp = Net::SFTP.start(''host'', ''username'', :password => ''password'') On May 28, 12:07 pm, Jaroslaw Zabiello <hipertrac...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> No, The same error appears on my Power Mac OSX 10.5.7 > > $ cat data-sync.rb > > require ''rubygems'' > require ''net/sftp'' > host, user, passwd = ''10.50.33.100'', ''login'', ''pass'' > path = ''/var/cms/storenew/workspace/live/data'' > Net::SFTP.start(host, user, passwd) do |sftp| > sftp.file.open(path, ''r'') do |f| > puts f.gets() > end > end > > Error for Ruby 1.8.6 EE: > > $ ruby -v > ruby 1.8.6 (2008-08-08 patchlevel 286) [i686-darwin9.6.0] > > $ ruby data-sync.rb > /opt/ruby-enterprise-1.8.6-20090201/lib/ruby/gems/1.8/gems/net- > sftp-2.0.2/lib/net/sftp.rb:43:in `start'': undefined method `shutdown!'' > for nil:NilClass (NoMethodError) > from data-sync.rb:7 > > And the same for Ruby 1.9: > > $ ruby1.9 -v > ruby 1.9.1 (2008-12-30 patchlevel-0 revision 21203) [i386-darwin9] > > $ ruby1.9 data-sync.rb > /opt/local/lib/ruby1.9/gems/1.9.1/gems/net-sftp-2.0.2/lib/net/sftp.rb: > 43:in `rescue in start'': undefined method `shutdown!'' for nil:NilClass > (NoMethodError) > from /opt/local/lib/ruby1.9/gems/1.9.1/gems/net-sftp-2.0.2/lib/net/ > sftp.rb:31:in `start'' > from data-sync.rb:7:in `<main>'' > > On Apr 8, 11:30 am, Conrad Taylor <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On Wed, Apr 8, 2009 at 1:09 AM, Shripad <shripad.josh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi, > > > > I updated the gem. > > > but still it is showing me the same error. > > > I am using windows, is that a problem for SFTP? > > > IS OpenSSH require for SFTP to connect to remote machine? > > > Is there any other way to do this? > > > > Thanks and Regards, > > > Shripad > > > Shripad, I''m not sure of the state of Capistrano on Windows. I''m sure that > > you''ll need the OpenSSH library installed on your system. Thus, it may be > > easier to install Cygwin and install OpenSSH from there. Otherwise, you can > > switch to Linux or Mac OS X or other Unix variant. > > > Good luck, > > > -Conrad > > > > On Apr 8, 12:58 pm, Conrad Taylor <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > On Wed, Apr 8, 2009 at 12:08 AM, Shripad <shripad.josh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > wrote: > > > > > > Hi, > > > > > Thanks Conrad for ur urgent reply > > > > > > What I want to do is just pickup the images from machine A to machine > > > > > B. > > > > > > I did what you say but I am getting error as follows > > > > > > E:/InstantRails/ruby/lib/ruby/gems/1.8/gems/net-sftp-2.0.2/lib/net/ > > > > > sftp.rb:43:in > > > > > `start'': undefined method `shutdown!'' for nil:NilClass > > > > > (NoMethodError) > > > > > from SSHTransfer.rb:8 > > > > > > what I write is this > > > > > sftp=Net::SFTP.start(''132.147.161.159'', ''k'',:password => ''k'') > > > > > > Thanks and Regards > > > > > > On Apr 8, 11:24 am, Conrad Taylor <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > On Tue, Apr 7, 2009 at 10:27 PM, Shripad <shripad.josh...@gmail.com> > > > > > wrote: > > > > > > > > Hi all, > > > > > > > > I am having following code in ruby > > > > > > > > require ''net/ssh'' > > > > > > > require ''net/sftp'' > > > > > > > begin > > > > > > > Net::SSH.start > > > > > > > (''132.147.161.159'',:password=>''k'',:port=>1234,:username=>''k'') do > > > |ssh| > > > > > > > ssh.sftp.connect do |sftp| > > > > > > > Dir.foreach(''.'') do |file| > > > > > > > puts file > > > > > > > end > > > > > > > end > > > > > > > end > > > > > > > rescue Exception=> Ex > > > > > > > puts Ex.message > > > > > > > end > > > > > > > > After executing the above code it is giving me following error > > > > > > > > Bad file descriptor - connect(2) > > > > > > > > username, password, and ipaddress are fine > > > > > > > > What I want is to take data from remote machine to server. > > > > > > > > Please Help me out. > > > > > > > > Thanks and Regards, > > > > > > > Shri > > > > > > > What are you wanting to do? SFTP or SSH? From the code, > > > > > > it appears that you''re trying to move a file from point A to B. > > > > > > Thus, here''s a brief outline of the things that you can do with > > > > > > SFTP: > > > > > > > require ''net/sftp'' > > > > > > > Net::SFTP.start(''host'', ''username'', :password => ''password'') do > > > |sftp| > > > > > > # upload a file or directory to the remote host > > > > > > sftp.upload!("/path/to/local", "/path/to/remote") > > > > > > > # download a file or directory from the remote host > > > > > > sftp.download!("/path/to/remote", "/path/to/local") > > > > > > > # grab data off the remote host directly to a buffer > > > > > > data = sftp.download!("/path/to/remote") > > > > > > > # open and write to a pseudo-IO for a remote file > > > > > > sftp.file.open("/path/to/remote", "w") do |f| > > > > > > f.puts "Hello, world!\n" > > > > > > end > > > > > > > # open and read from a pseudo-IO for a remote file > > > > > > sftp.file.open("/path/to/remote", "r") do |f| > > > > > > puts f.gets > > > > > > end > > > > > > > # create a directory > > > > > > sftp.mkdir! "/path/to/directory" > > > > > > > # list the entries in a directory > > > > > > sftp.dir.foreach("/path/to/directory") do |entry| > > > > > > puts entry.longname > > > > > > end > > > > > > end > > > > > > > Good luck, > > > > > > > -Conrad > > > > > Can you upgrade the gem and retrying what you > > > > did before? You can upgrade by doing the following: > > > > > sudo gem update > > > > > -Conrad
Seemingly Similar Threads
- rails2.3/ruby1.9: invalid byte sequence in utf-8 with blank?
- invalid byte sequence utf-8 OR best option to sanitize content brought in with net::http? single non-utf character causes rails to crash
- Recording a Live Earning Cast call
- Extremely slow start up with ruby 1.9.1 vs 1.8.7
- Using MacPorts To Install Ruby 1.9.1 and Rails 2.3.0 RC1