Forum: Ruby Connecting via Net::Telnet

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Will S. (Guest)
on 2006-01-03 08:52
(Received via mailing list)
Thanks for all the suggestions in the previous email about getting
started.  I looked at a lot of resources today and thought I would
just get started. :)

The first thing I have to do is get connected and logged in.  However doesn't use a traditional telnet login prompt.  it
uses a menu displayed with a => prompt waiting for user input.  So
here is what I have so far.  it does connect :) but I can't get logged

require 'net/telnet'

# Telnet into the Nethack server and login
# The Nethack server doesn't have a traditional telnet login.  It used
a "=> " prompt where you enter
# a letter from a menu displayed

host = Net::Telnet::new("Host" => "",
				  "Port" => 23,
				  "Timeout" => 10) { |str| print str }
host.waitfor('=>') { |str| print str }
host.puts("l") { |str| print str }

Here is the output:

E:\Ruby\mkNethackbot>ruby mkNethackbot.rb
Connected to
Debian GNU/Linux 3.0
Error opening terminal: network.
c:/ruby/lib/ruby/1.8/net/telnet.rb:551:in `waitfor': timed out while
waiting for
 more data (Timeout::Error)
        from mkNethackbot.rb:20

I found the code "{ |str| print str }" on another site using Ruby's
net/telnet, but I don't yet know exactly what it means, but I think it
waits for any strings sent ( |str |) and then displays it ( print str


Will S.  ( )
Home Page:

When you get to your wit's end, you'll find God lives there.
This topic is locked and can not be replied to.