net-telnet
net-telnet copied to clipboard
Cmd function only accept Prompt for waitfor
I deal with a server that never send any prompt. So the cmd can't find any match string. I tried a correction (given here). I suggest to have a cmd option and to be able to send either a Prompt or a Match or a String option to the wait for to avoid the raise of a "tile out while waiting for more data". Is my solution correct ? Could it be possible to include this kind of solution in a next version of this project ?
def cmd(options) # :yield: recvdata
match = @options["Prompt"]
time_out = @options["Timeout"]
fail_eof = @options["FailEOF"]
typeMatch = "Prompt"
if options.kind_of?(Hash)
cmd = options["Cmd"] if options.has_key?("String")
if options.has_key?("String")
match = options["String"]
typeMatch="String"
end
if options.has_key?("Match")
match = options["Match"]
typeMatch="Match"
end
time_out = options["Timeout"] if options.has_key?("Timeout")
fail_eof = options["FailEOF"] if options.has_key?("FailEOF")
else
cmd = options
end
self.puts(cmd)
if block_given?
waitfor({typeMatch => match, "Timeout" => time_out, "FailEOF" => fail_eof}){|c| yield c }
else
waitfor({typeMatch => match, "Timeout" => time_out, "FailEOF" => fail_eof})
end
end