From: Brian Candler Date: 2010-01-26T19:29:44+09:00 Subject: Re: Problems with Telnet Sean Warburton wrote: > I can open a connection no problem and if I send the following command > > cmd("domain1.ca\r\ndomain2.ca\r\n#exit") {|str| print str} > > I get the information I need returned for both domains but because I > need to wait 200ms between each domain, I need to actually send ... > > cmd("domain1.ca\r\n"){|str| print str} > sleep 0.2 > cmd("domain2.ca\r\n#exit"){|str| print str} > > When I do that I get the correct information for the first domain then > it sits for a couple of seconds before returning a timed out error. It's waiting for a "prompt". Having a look at the source code of Net::Telnet to see what the default is, but you can override it, either when you connect, or each time you sent a command: cmd("String"=>"domain1.ca\r\n", "Match"=>/OK>/) What you match depends entirely on how the server implements its protocol of course, but basically you want to match whatever the sequence of characters is that says "OK, I'm done, now send me another command" If it just sends you a one-line reply then maybe you just want to match /\r\n/ This will give you a lock-step request-response. You may or may not need the 200ms sleep (maybe the server always pauses 200ms before responding?) HTH, Brian. -- Posted via http://www.ruby-forum.com/.