Towards a MUD client, I'm using telnet.
I'm trying to get the weather like Apache does, but this error seems to, probably, be that I'm not using the em-simple_telnet API correctly.
error:
thufir@dur:~/ruby$
thufir@dur:~/ruby$ ruby weather.rb
{"host"=>"rainmaker.wunderground.com", "port"=>3000}
/home/thufir/.rvm/gems/ruby-2.0.0-p247/gems/em-simple_telnet-0.0.14/lib/em-simple_telnet.rb:712:in `pause_and_wait_for_result': EventMachine::Protocols::SimpleTelnet::ConnectionFailed (EventMachine::Protocols::SimpleTelnet::ConnectionFailed)
from /home/thufir/.rvm/gems/ruby-2.0.0-p247/gems/em-simple_telnet-0.0.14/lib/em-simple_telnet.rb:246:in `connect'
from /home/thufir/.rvm/gems/ruby-2.0.0-p247/gems/em-simple_telnet-0.0.14/lib/em-simple_telnet.rb:191:in `block in new'
thufir@dur:~/ruby$
code:
#!/usr/bin/env ruby
require 'rubygems'
require 'em-simple_telnet'
require 'yaml'
require 'pry'
require 'pp'
opts = YAML.load_file('params.yml')
pp opts
EM::P::SimpleTelnet.new(opts) do |host|
puts host.cmd("ls -la")
end
Here's a telnet session with the weather service:
thufir@dur:~/ruby$
thufir@dur:~/ruby$
thufir@dur:~/ruby$ telnet rainmaker.wunderground.com 3000
Trying 38.102.137.140...
Connected to rainmaker.wunderground.com.
Escape character is '^]'.
------------------------------------------------------------------------------
* Welcome to THE WEATHER UNDERGROUND telnet service! *
------------------------------------------------------------------------------
* *
* National Weather Service information provided by Alden Electronics, Inc. *
* and updated each minute as reports come in over our data feed. *
* *
* **Note: If you cannot get past this opening screen, you must use a *
* different version of the "telnet" program--some of the ones for IBM *
* compatible PC's have a bug that prevents proper connection. *
* *
* comments: [email protected] *
------------------------------------------------------------------------------
Press Return to continue:
Press Return for menu
or enter 3 letter forecast city code-- dca
Weather Conditions at 12:27 AM EDT on 29 Aug 2013 for Washington, DC.
Temp(F) Humidity(%) Wind(mph) Pressure(in) Weather
========================================================================
75 89% NE at 7 29.85 Overcast
Forecast for Washington, MD
1030 PM EDT Wed Aug 28 2013
.Rest of tonight...Cloudy. Scattered showers late this evening...
then isolated showers. Patchy fog. Lows around 70. South winds
around 5 mph...becoming east. Chance of rain 50 percent.
.Thursday...Mostly cloudy in the morning...then becoming mostly
sunny. Patchy fog in the morning. Scattered sprinkles. Highs in the
lower 80s. Northeast winds 5 to 10 mph.
.Thursday night...Partly cloudy. Scattered sprinkles in the evening.
Lows in the mid 60s. East winds around 5 mph...becoming north after
midnight.
.Friday...Mostly sunny. Highs in the lower 80s. North winds around
5 mph...becoming southeast in the afternoon.
.Friday night...Partly cloudy in the evening...then becoming mostly
cloudy. Lows in the upper 60s. South winds around 5 mph.
.Saturday...Partly sunny. Highs in the mid 80s.
.Saturday night...Mostly cloudy. Lows in the upper 60s.
Press Return to continue, M to return to menu, X to exit: x
Connection closed by foreign host.
thufir@dur:~/ruby$
thufir@dur:~/ruby$
Patrik seems to have answered this, I think. Here's the results:
code:
Wasn't using the API properly, didn't realize.