0

I am new to ExpectIt API. I can execute command and got a response, but I cannot stop running command by giving escape keys (ctrl+shift+6).

How do I can send escape keys to the terminal to stop running command through ExpectIt API ?

example

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#
Visva
  • 194
  • 1
  • 3
  • 11

1 Answers1

0

I stopped the running command on router by sending the control keys two times as like following.

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

and I have taken source of the expectIt, changed the following class.

ExpectImpl.java 
 //private final OutputStream output; 
 private final Writer output; // use Writer instead of using OutputStream
Visva
  • 194
  • 1
  • 3
  • 11
  • Have you tried Expect#sendBytes method? It should work the same way: exepect.sendBytes(new byte[] { 30 }) (30 decimal = 1E hex). – Alexey Gavrilov Dec 02 '16 at 20:05
  • It should work via the output stream as well. There is no need to use Writer. Can you show the exact code which doesn't work? I'd like to investigate the root cause and make changes to ExpectIt if any. – Alexey Gavrilov Dec 04 '16 at 13:32