groovy-ssh
groovy-ssh copied to clipboard
PR for issue #60: expect-like interaction support
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
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.
#60