expectit sendLine function is removing space and character from command string

23 views
Skip to first unread message

Vkm Chandel

unread,
Oct 17, 2020, 1:19:29 PM10/17/20
to Yet another Expect for Java

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.

Reply all
Reply to author
Forward
0 new messages