I am doing some maintenance on some network devices and I've been using Expectit to navigate through the menus. However, I've only been successful when the devices provide prompts I expect. For example, some devices are already in enable mode when I log in, but some are not.
I would like to do the equivalent of:
Expect expect = new ExpectBuilder()
.withOutput(channel.getOutputStream())
.withInputs(channel.getInputStream(), channel.getExtInputStream())
.withEchoOutput(wholeBuffer)
.withEchoInput(wholeBuffer)
.withExceptionOnFailure()
.build();
channel.connect();
if (expect.expect(contains(">")) {
expect.sendLine("enable");
expect.expect("assword:");
expect.sendLine(password);
}
expect.expect(contains("#"));
but I know this isn't right and it doesn't work. Some assistance on implementing a reaction to a certain prompt and another reaction to other prompts would be appreciated. Thanks!