'How to disable control characters received with Expect.pm
I am using Expect.pm to connect with SSH to a remote server. While connected, I'm sending commands via the Expect object, and I receive answers from the remote server with it's control characters:
spawn id(22): Does `show \r\033[Kadmin@host> show log \r\033[Kadmin@host> show log config \r\033[Kadmin@host> show log config result \r\033[Kadmin@host> show log config result equal \r\033[Kadmin@host> show log config result equal succeeded\r\n\033[?1h\033=\033[@959;1H\033[K'
All these control characters are messing my pattern matching done with Expect. My question is: How can I avoid seeing these control characters in the returning characters?
Solution 1:[1]
It seems some of the control characters are coming from the PS1 environvement variable, try setting that to something different after you establish the ssh session. In bash that would be:
export PS1="dummy_prompt> "
It's also worth checking what kind of environvement you have with the below command
env
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Georgi Rangelov |
