I am using expectit 0.9.0 and java version 1.8.0_201, expect.sendLine()
is perfectly working with single words commands but when it comes to
multiple words command, it is behaving weird, sometimes it removes the
space and sometimes removes any single character from the command
string.
Entered Command: esxcli network ip interface ipv4 get
Behavior :`
- esxcli network ip terface ipv4 get
- esxcli network ipinterface ipv4 get
This behavior is not consistence, some time it work perfectly.
Below is my code -
try {
String username="root";
String password="root_password";
Process process = Runtime.getRuntime()
.exec("ipmitool -I lanplus -H <myipaddress> -U <admin_username> -P <admin_pasword> sol activate");
Expect expect = new ExpectBuilder()
.withInputs(process.getInputStream())
.withOutput(process.getOutputStream())
.withTimeout(50, TimeUnit.SECONDS)
.withExceptionOnFailure()
.build();
try {
expect.sendLine();
expect.sendLine("esxcli network ip interface ipv4 get");
expect.sendLine("ENDCOMMAND");
System.out.println(expect.expect(contains("ENDCOMMAND")).getBefore());
}catch (Exception e) {
e.printStackTrace();
}
Please help me in this.Thanks in Advance.