Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cmd function only accept Prompt for waitfor #30

Open
pommechocolat opened this issue Jan 23, 2023 · 0 comments
Open

Cmd function only accept Prompt for waitfor #30

pommechocolat opened this issue Jan 23, 2023 · 0 comments

Comments

@pommechocolat
Copy link

pommechocolat commented Jan 23, 2023

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant