From: Brian Candler Date: 2009-07-23T16:36:53+09:00 Subject: Re: Telnet Ruby Amogh Gonwar wrote: > I am looking at bdi.send_1 to send instructions when the @promt is /-- > Target stopped/. I need to add a procedure in rbdi.rb for send_1 which > sends commands @prompt /-- Target stopped/, and I am unable to do this. Sorry, you've lost me there. You can set the expected prompt on each call to Net::Telnet#cmd as an option, which you should be able to pass through to your RBDI#send method: bdi.send("Prompt" => /-- Target stopped/) Or is the problem that you might have two possible prompts in response to one command? Then you can do res = @connection.cmd("Prompt" => /-- Target stopped|BDI>/) and check the value of res to see which of the two patterns was matched, and take action accordingly. Or is the problem that you want to send N different commands with N different prompts? Then you can pass an array of arrays, or an array of hashes: bdi.send([ {"String"=>"cmd1", "Prompt"=>/Prompt1/}, {"String"=>"cmd2", "Prompt"=>/Prompt2/}, ]) Again, I must stress this: try to boil your problem down to as small a possible test case which shows the problem you are having. In this case I think it should be 10 lines or less. There are three important reasons for doing this: 1. In the process of boiling it down, you may find and fix the problem 2. In the process of boiling it down, you will in any case learn more about what you're trying to do 3. It makes it much, much easier for someone to help you, when you can point to exactly where the problem lies. In the above reply I had to guess what your problem is, which wastes my time, and probably didn't solve the problem anyway. Regards, Brian. -- Posted via http://www.ruby-forum.com/.