groovy-ssh icon indicating copy to clipboard operation
groovy-ssh copied to clipboard

PR for issue #60: expect-like interaction support

Open rzabini opened this issue 10 years ago • 2 comments

Hi, here is the pull request with the proposed changes. As I wrote in the issue description, and can be seen in the tests, a shellExpect instruction may be added to the ssh session. The shellExpect has a closure parameter which is a succession of send and expectOrThrow elements: send executes a command, expectOrThrow waits for a specified number of seconds for a pattern to appear on the command output. It throws a TimeoutException if the pattern does not appear. Thank you, Romano

rzabini avatar Apr 23 '15 21:04 rzabini

Great! This approach is useful for not only shell but execute, as following example:

// executing a shell
shell expect: {
  send 'hello server'
  expectOrThrow 1,'please enter password:'
}
// executing a command
execute 'some command', expect: {
  send 'hello server'
  expectOrThrow 1,'please enter password:'
}

I will add some enhance on the given pull request and merge it. Please let me know if you have some idea. Thank you.

int128 avatar May 03 '15 13:05 int128

#60

int128 avatar May 03 '15 13:05 int128