Well, I don’t get it, I have no idea why the sample code doesn’t work
for
me. It appears to be a matter of ?importing? the gem correctly. What’s
the correct syntax, please? How do you know what the syntax is to ?
import? the gem correctly?
thufir@dur:~/ruby/ssh$
thufir@dur:~/ruby/ssh$ ruby ssh.rb
trying to connect…
ssh.rb:10:in <main>': undefined local variable or method ssh’ for
main:Object (NameError)
thufir@dur:~/ruby/ssh$
thufir@dur:~/ruby/ssh$ nl ssh.rb
1 require ‘rubygems’
2 require ‘net/ssh/telnet’
3 puts "trying to connect..."
4 s = Net::SSH::Telnet.new(
5 "Dump_log" => "/dev/stdout",
6 "Session" => ssh
7 )
8 puts "Logged in"
9 p s.cmd("echo hello")
s = Net::SSH::Telnet.new(
“Dump_log” => “/dev/stdout”,
“Host” => “127.0.0.1”,
“Port” => 119 as part
…
ah, ok. I thought I’d tried that, but apparently not. There’s no
login,
I just would like to pass some commands to leafnode and get the
response.
Am I not getting the output correctly?
thufir@dur:~/ruby/ssh$
thufir@dur:~/ruby/ssh$ ruby ssh.rb
trying to connect…
0x00000: 54 72 79 69 6e 67 20 31 32 37 2e 30 2e 30 2e 31 Trying
127.0.0.1
0x00010: 2e 2e 2e 0a …
/home/thufir/.rvm/gems/ruby-1.9.3-p125/gems/net-ssh-telnet-0.0.2/lib/net/
ssh/telnet.rb:219:in rescue in initialize': timed out while opening a connection to the host (Timeout::Error) from /home/thufir/.rvm/gems/ruby-1.9.3-p125/gems/net-ssh- telnet-0.0.2/lib/net/ssh/telnet.rb:208:ininitialize’
from ssh.rb:5:in new' from ssh.rb:5:in’
thufir@dur:~/ruby/ssh$
thufir@dur:~/ruby/ssh$ nl ssh.rb
1 require ‘rubygems’
2 require ‘net/ssh/telnet’
you’re right, when I read that last night I was a bit tired.
I’m trying to look at the corresponding API for “non-ssh” telnet, to
figure out how to login to leafnode and get the output printed to the
screen. I just get timeouts so far:
thufir@dur:~/ruby/ssh$
thufir@dur:~/ruby/ssh$ ruby ssh.rb
trying to connect…
0x00000: 54 72 79 69 6e 67 20 31 32 37 2e 30 2e 30 2e 31 Trying
127.0.0.1
0x00010: 2e 2e 2e 0a …
[1]+ Stopped ruby ssh.rb
thufir@dur:~/ruby/ssh$
thufir@dur:~/ruby/ssh$ /home/thufir/.rvm/gems/ruby-1.9.3-p125/gems/net-
ssh-telnet-0.0.2/lib/net/ssh/telnet.rb:219:in rescue in initialize': timed out while opening a connection to the host (Timeout::Error) from /home/thufir/.rvm/gems/ruby-1.9.3-p125/gems/net-ssh- telnet-0.0.2/lib/net/ssh/telnet.rb:208:ininitialize’
from ssh.rb:5:in new' from ssh.rb:5:in’
In fact, it doesn’t even seem to be “logging in” since that put never
executes. Am I using the right API? If so, how do I get the response
which “telnet localhost nntp” brings up in the terminal?
thanks,
Thufir
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.