From: Wolfgang Schorer Date: 2001-08-05T06:54:21+09:00 Subject: [ruby-talk:19150] Re: telnet.rb ECONNRESET You should be able to catch this by an exception. Begin pop . . rescue catch the reset here end > I am trying to write a script that checks if a pop password is correct or not. > The problem is the server closes the connection when it is incorrect and ruby > just dies with the message: > > ------------------------------------------------------------ > /usr/lib/ruby/1.6/net/telnet.rb:474:in `sysread': Connection reset by peer > (Errno::ECONNRESET)' > from /usr/lib/ruby/1.6/net/telnet.rb:474:in `waitfor' > ------------------------------------------------------------ > > my current code: > > ------------------------------------------------------------ > pop = Net::Telnet::new({"Host" => pop_server, > "Port" => pop_port, > "Telnetmode" => true, > "Timeout" => 30, > "Output_log" => "output_log", > "Prompt" => /^\+OK/n}) > pop.cmd("user " + pop_username){|c| print c} > pop.cmd("pass " + pop_password){|c| print c} > ------------------------------------------------------------ > > and now I need some kind of check if it the server closes the > connection/returns "+ERR" or return "+OK". Anyone got an idea ? > > > -- > Linux, the choice | Back in the 1970s we didn't have the space > of a GNU generation -o) | shuttle to get all excited about. We had to > Kernel 2.4.8-pre /\ | settle for men walking on the crummy moon. > on a i686 _\_v | -Russell Beland > | > Wolfgang. Phone 407-299-0273 Fax 407-299-4058