diff --git a/aexpect/client.py b/aexpect/client.py index e0460f4..6996897 100644 --- a/aexpect/client.py +++ b/aexpect/client.py @@ -1218,6 +1218,8 @@ def cmd_output(self, cmd, timeout=60, internal_timeout=None, self.sendline(cmd) try: out = self.read_up_to_prompt(timeout, internal_timeout, print_func) + # Removing escape sequence from output! + out_no_escape = astring.strip_console_codes(out) except ExpectTimeoutError as error: output = self.remove_command_echo(error.output, cmd) raise ShellTimeoutError(cmd, output) from error @@ -1229,7 +1231,7 @@ def cmd_output(self, cmd, timeout=60, internal_timeout=None, raise ShellError(cmd, output) from error # Remove the echoed command and the final shell prompt - return self.remove_last_nonempty_line(self.remove_command_echo(out, + return self.remove_last_nonempty_line(self.remove_command_echo(out_no_escape, cmd)) def cmd_output_safe(self, cmd, timeout=60):