From: sto.mar@... Date: 2013-03-09T03:16:42+09:00 Subject: Re: telnet - how to loop through commands listed in a file Am 08.03.2013 17:54, schrieb Bob Ford: > I've now run into a little conundrum. There is one command that can > take up to 15 seconds to complete so I attempted to put in a simple "if" > > ========== snippet ========== > if #{line} == 'w s' You want: if line == 'w s' #{line} only makes sense in a double quoted string, without quotes you are starting a comment here! I think you should read up on some basic Ruby syntax, try e.g. http://pine.fm/LearnToProgram/. Generally, placing puts statements like 'puts your_var.inspect' or 'p your_var' just before "critical" places in your code could help you understand what's going wrong. And you should develop a habit of testing (simplified) code snippets with irb. > puts "The commands is: #{line}\nWe should be sleeping for 15 > seconds\n" > telnet.cmd(line.gsub("\"", "")) { |c| print c } > sleep 15 > else > telnet.cmd(line.gsub("\"", "")) { |c| print c } > end > > ========== end snippet ========== > > The "puts" prints for every single line. The sleep is never > encountered. I had placed an exit right under the "puts". The "else" > line is the one being executed. > > I assumed the "puts" the telnet.cmd and then the sleep would only happen > if #{line} equaled "w s". > > Once again I ask you out there what am I doing wrong? > --