How to disable control characters received with Expect.pm

272 Views Asked by At

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?

1

There are 1 best solutions below

0
Georgi Rangelov On

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