I am using the amazing expectit java library https://github.com/Alexey1Gavrilov/ExpectIt and have implemented the following which basically ssh into another Linux device and gets the response for the command I send to the Liniux device.
Below is a sample code snippet that I use:
expect.sendLine("command to remove Linux device");
final Result cmdResult = expect.interact()
.when(contains("Press any key to continue (Q to quit)")).then({expect.sendLine()})
.until(contains(">"));
On the device itself, there are around 10 pages so the enter key press is simulated for around 10 times as per the above logic.
This works fine in terms of interaction with the remote device. but I am having trouble getting the responses back.
When I try and call any of the methods on the Result class, such as getInput(), getBefore() etc, it does not have the complete list but looks like the last interaction.
What I suspect is I need to capture and store the responses before each enter key press is simulated.
I have been trying quite a few things unsuccessfully.
Has anyone got any idea how to capture the complete response from the remote Linux device when it has multiple pages?
Cheers
Travis
I was able to solve my issue by following this post https://groups.google.com/d/topic/java-expectit/Oktf1lsNUT4/discussion
By doing the following, I was able to get rid of the pagination and so this is no longer an issue.
expect.sendLine("term length 0");