0

我是 ExpectIt API 的新手。我可以执行命令并得到响应,但我不能通过给出转义键(ctrl+shift+6)来停止运行命令。

如何通过 ExpectIt API 向终端发送转义键以停止运行命令?

例子

R1#ping ip 192.168.1.1
    Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
.... <div style="color:red"><b>I pressed escapse character here</b></div>
Success rate is 0 percent (0/4)
R1#
4

1 回答 1

0

我通过发送控制键两次来停止路由器上的运行命令,如下所示。

char ctrlKey = (char) Integer.parseInt("1E", 16);
expect.send(ctrlKey);
Thread.sleep(1000);
expect.send(ctrlKey);

我已经获取了expectIt的来源,更改了以下课程。

ExpectImpl.java 
 //private final OutputStream output; 
 private final Writer output; // use Writer instead of using OutputStream
于 2016-11-28T09:34:11.240 回答