ruby / ruby/net-telnet

Cmd function only accept Prompt for waitfor

Open
#30 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
57
Forks
36
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the cmd and waitfor entry points, focusing on how cmd selects its wait condition and how waitfor handles Prompt, Match, and String options. Define the supported option behavior and verify that a command can wait for a match or string without raising the timeout described in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
networking
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.