[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Read file over SSH

Shashank Agarwal

8/2/2008 5:30:00 PM

Is there a way to read a file over SSH? I looked at the net/ssh library
but couldn't put together a working code.

Thanks.
--
Posted via http://www.ruby-....

5 Answers

Ståle Z.H

8/2/2008 6:18:00 PM

0

On 2 Aug, 19:29, Shashank Agarwal <shashank...@yahoo.com> wrote:
> Is there a way to read a file over SSH? I looked at the net/ssh library
> but couldn't put together a working code.
>
> Thanks.
> --
> Posted viahttp://www.ruby-....

You're probably interested in Net::SCP:
http://net-ssh.rubyforge.org/scp/v1/api/...

Phlip

8/2/2008 6:21:00 PM

0

Shashank Agarwal wrote:

> Is there a way to read a file over SSH? I looked at the net/ssh library
> but couldn't put together a working code.

Here's a wild guess - does it help?

require 'net/ssh'
require 'net/sftp'

Net::SSH.start( 'myserver', 'myname', 'mypassword' ) do |session|
session.sftp.connect do |sftp|
sftp.get_file('path/filename', 'filename')
end
end

--
Phlip

Shashank Agarwal

8/3/2008 5:04:00 PM

0

Thanks for your replies. I'll look into SCP and try using SFTP. :)
--
Posted via http://www.ruby-....

James Dinkel

8/4/2008 12:27:00 AM

0

Shashank Agarwal wrote:
> Thanks for your replies. I'll look into SCP and try using SFTP. :)

Just FYI:

The terms are regularly used interchangeably, but it's "SFTP" what you
will use. "SCP" is the original file transfer protocol over ssh, but it
is not in use anymore unless you have a really really old server you are
connecting to. "SFTP" is the new protocol that in use on modern ssh
servers.
--
Posted via http://www.ruby-....

James Dinkel

8/4/2008 3:41:00 PM

0

Chad Perrin wrote:
>
> Of course, I'm pretty sure the scp command I use is just an interface
> for
> the SFTP protocol that behaves the way the old scp program that used the
> SCP protocol worked.

Yeah, that's probably correct. There are scp and sftp commands for
linux, but they should both use the sftp protocol (there are just usage
differences between the two programs). Ruby's scp and sftp methods may
be different though.

It's all very confusing, I know.
--
Posted via http://www.ruby-....