我正在对一些网络设备进行一些维护,并且一直在使用 Expectit 浏览菜单。但是,我只有在设备提供我期望的提示时才成功。例如,当我登录时,有些设备已经处于启用模式,但有些不是。
我想做相当于:
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("#"));
但我知道这是不对的,而且它不起作用。对实现对某个提示的反应和对其他提示的另一种反应的一些帮助将不胜感激。谢谢!