# Net::Telnet and sysread()

**URL:** <https://www.ruby-forum.com/t/net-telnet-and-sysread/51652>\
**Category:** Ruby\
**Created:** [January 5, 2006, 7:26am UTC](https://www.ruby-forum.com/t/net-telnet-and-sysread/51652 "2006-01-05T07:26:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![combray](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/eada6e/32.png) [@combray](https://www.ruby-forum.com/u/combray)\
**Post date:** [January 5, 2006, 7:26am UTC](https://www.ruby-forum.com/t/net-telnet-and-sysread/51652/1 "2006-01-05T07:26:11Z")

</div>

I’m trying establish a telnet connection to [nethack.alt.org](http://nethack.alt.org). I can  
get a connection but Net::Telnet cannot seem to handle the output. In  
reading net/telnet.rb I found out about IO#sysread so i put this  
little tnet.rb file together

require ‘net/telnet’

print(“\n”)  
tn = Net::Telnet.new(  
‘Host’ =\> ‘[nethack.alt.org](http://nethack.alt.org)’,  
‘Timeout’ =\> 10,  
‘Telnetmode’ =\> true) { |str| print str }

input = tn.sysread(1024 \* 1024)  
print("\nDisplaying Output\n ")  
print(input)

Now when I connect here is the output that is displayed:  
E:\Ruby\mkNethackbot\>ruby tnet.rb

Trying [nethack.alt.org](http://nethack.alt.org)…  
Connected to [nethack.alt.org](http://nethack.alt.org).

Displaying Output  
©÷¡è ©÷ ©÷# ©÷’E:\Ruby\mkNethackbot\>

As you can see from the “Displaying Output” section the data that  
[nethack.alt.org](http://nethack.alt.org) is sending doesn’t seem readable by Net::Telnet.  
[nethack.alt.org](http://nethack.alt.org) appears to use a scripted login instead of a standard  
login/password prompt.

Any ideas?

Thanks,  
Will

–  
Will S. ( [willshattuck.at.gmail.com](http://willshattuck.at.gmail.com) )  
Home Page: [http://www.thewholeclan.com/will](http://www.thewholeclan.com/will)

When you get to your wit’s end, you’ll find God lives there.
