how to implement expect "interact" command using java
In case anyone is interested, I have added basic interactive loop support to ExpectIt, my own open source Expect for Java implementation (sorry for self-promotion), since version 0.8.
Here is an example of interacting with the system input stream in Java 8:
try (final Expect expect = new ExpectBuilder() .withInputs(System.in) .build()) { expect.interact() .when(contains("abc")).then(r -> System.out.println("A")) .when(contains("xyz")).then(r -> System.err.println("B")) .until(contains("exit")); System.out.println("DONE!"); } System.in.close();