From: sto.mar@... Date: 2013-03-09T04:24:40+09:00 Subject: Re: telnet - how to loop through commands listed in a file Am 08.03.2013 20:14, schrieb Bob Ford: > unknown wrote in post #1100737: >> 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. > > Yes I see I've forgotten the quotes. I had inadvertently stripped them > off trying different things. you should not use them here, just do if line == 'w s' puts 'yes' else puts 'no' end If that does not solve your problem, place p line just before your if expression in order to see what 'line' actually contains. There could be a newline character at the end, if so, you can use 'chomp' (line.chomp) to get rid of it. ("w b\n" and "w b" are different.) > I've read and googled and I know I'm horrible at Ruby. I only posted > here as a last resort. > > Nothing I have attempted has worked. I know I'm missing something very > simple and hoped someone here might have been able to point me in the > correct direction. > > Please forgive my ignorance and please forgive my asking for help on the > forum. It'll not happen again. No problem at all. Just ask. --