2013-08-29 10 views
0

MUD client으로 텔넷을 사용하고 있습니다.em-simple_telnet.rb 오류 'pause_and_wait_for_result'

날씨가 like Apache does인데이 오류는 아마도 em-simple_telnet API을 올바르게 사용하지 않는 것으로 보입니다.

오류 :

[email protected]:~/ruby$ 
[email protected]:~/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' 
[email protected]:~/ruby$ 

코드 :

#!/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 

여기 날씨 서비스를 텔넷 세션의 :

[email protected]:~/ruby$ 
[email protected]:~/ruby$ 
[email protected]:~/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. 
[email protected]:~/ruby$ 
[email protected]:~/ruby$ 

답변

1

좋아, 내가 첫 번째 링크를 참조하십시오. 그것은 말한다 : 그것은 MUD에서 어떤 반응을하지 않는 경우

A MUD client is a computer application used to connect to a MUD, a type of multiplayer online game. Generally, a MUD client is a very basic telnet client that lacks VT100 terminal emulation and the capability to perform telnet negotiations.

불행하게도, 나는 그 시간을 텔넷 보석 텔넷 협상을하려고 생각하고. 텔넷 프로토콜을 따르지 않는 텔넷 클라이언트가 무엇을 의미하는지 확신 할 수 없습니다.

소켓이있는 MUD 서버에 연결해보십시오.

+0

그냥 명확히하기 위해 여기에 머드에 연결하지 않았습니다.이 것은 테스트 및 일러스트레이션을위한 기상 서비스입니다. 날씨를 확인할 수있게되면 재미와 게임으로 이동합니다 :) – Thufir

+0

나는 그것이 어떻게 관련이 있는지 알 수 없습니다. 날씨가 텔넷 서버입니까? – 7stud

+0

예, 날씨 서비스는 텔넷을 통해, vt100까지 알고 있습니다. 대부분의 CLI (Linux, Windows, Mac)의'telnet rainmaker.wunderground.com 3000'은 정상적으로 작동합니다. (머드의 경우도 마찬가지입니다.) – Thufir

1

em-simple_telnet의 readme에있는 예제를보십시오. EventMachine.run (...) 호출로 감싸 야합니다.

또한 "호스트"및 "포트"대신에 host 및 : port와 같은 키를 사용하십시오.

+0

나는 그것이 대답이라고 생각한다. 나의 대답은 당신의 대답을 사용한다. – Thufir

0

Patrik이 대답 한 것 같습니다. 여기서 결과는 다음과 같습니다

[email protected]:~/ruby$ 
[email protected]:~/ruby$ ruby weather.rb 
{"host"=>"rainmaker.wunderground.com", "port"=>3000} 
{:host=>"rainmaker.wunderground.com", :port=>"3000"} 
"opts and opts2 are different, didn't realize that" 
"seems to connect, just not sure yet how print server output" 
SimpleTelnet: EventMachine reactor had been started independently. Won't stop it automatically. 
#<EventMachine::Protocols::SimpleTelnet:0x9c25408 
@check_input_buffer_timer=nil, 
@connection_state=:connected, 
@fiber_resumer= 
    #<Proc:[email protected]/home/thufir/.rvm/gems/ruby-2.0.0-p247/gems/em-simple_telnet-0.0.14/lib/em-simple_telnet.rb:374 (lambda)>, 
@input_buffer="", 
@input_rest="", 
@last_command=nil, 
@logged_in=2013-08-29 06:50:13 -0700, 
@signature=2, 
@telnet_options= 
    {:host=>"rainmaker.wunderground.com", 
    :port=>"3000", 
    :prompt=>/[$%#>] \z/n, 
    :connect_timeout=>3, 
    :timeout=>10, 
    :wait_time=>0, 
    :bin_mode=>false, 
    :telnet_mode=>true, 
    :output_log=>nil, 
    :command_log=>nil, 
    :login_prompt=>/[Ll]ogin[: ]*\z/n, 
    :password_prompt=>/[Pp]ass(?:word|phrase)[: ]*\z/n, 
    :username=>nil, 
    :password=>nil, 
    :SGA=>false, 
    :BINARY=>false}, 
@wait_time_timer=nil> 

^C/home/thufir/.rvm/gems/ruby-2.0.0-p247/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine': Interrupt 
    from /home/thufir/.rvm/gems/ruby-2.0.0-p247/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run' 
    from weather.rb:9:in `<main>' 

[email protected]:~/ruby$ 
[email protected]:~/ruby$ 

코드 :

#!/usr/bin/env ruby 
require 'rubygems' 
require 'em-simple_telnet' 
require 'yaml' 
require 'pry' 
require 'pp' 


EventMachine.run do 

opts2 = YAML.load_file('params.yml') 

pp opts2 

    opts = { 
    host: "rainmaker.wunderground.com", 
    port: "3000", 
    } 


pp opts 

pp "opts and opts2 are different, didn't realize that" 
pp "seems to connect, just not sure yet how print server output" 

EM::P::SimpleTelnet.new(opts) do |host| 
    pp host 
end 

end 

제대로 API를 사용하지 않았다 실현하지 않았다.