From: TAKEUCHI Hideki Date: 2002-09-18T09:19:41+09:00 Subject: [ruby-list:35963] net/telnet.rb (example of POP) 竹内です。 ruby 1.6.5 (2001-09-19) [i686-linux] の net/telnet.rbにおける POPの例 === CHECKS A POP SERVER TO SEE IF YOU HAVE MAIL pop = Net::Telnet::new({"Host" => "your_destination_host_here", "Port" => 110, "Telnetmode" => false, "Prompt" => /^\+OK/n}) pop.cmd("user " + "your_username_here"){|c| print c} pop.cmd("pass " + "your_password_here"){|c| print c} pop.cmd("list"){|c| print c} =end において、最初の pop.cmdで telnet.rb:465:in `waitfor': timed-out; wait for the next data (TimeoutError) となり正常に動作しませんでした (POP3サーバーは SunOS 5.7, QPOP(version 2.53)です) 詳しく調べてはいないのですが Net::Telnet::waitforにおいて Telnetmodeが falseの時 buf が '' のままであることが直接の理由でした 正しい解決策はわからなかったのですが対処療法として以下のようにすると 期待どおりの結果が得られました pop = Net::Telnet::new({"Host" => "your_destination_host_here", "Port" => 110, # "Telnetmode" => false, # default のまま(true)にする "Prompt" => /^\+OK/n}) # 最初のcmdの前に promptを待つようにする pop.waitfor(/+OK/n) pop.cmd("user " + "your_username_here"){|c| print c} pop.cmd("pass " + "your_password_here"){|c| print c} pop.cmd("list"){|c| print c} とりあえずお知らせしておきます -- 竹内英樹