0

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?

codewario
  • 19,553
  • 20
  • 90
  • 159
user116969
  • 387
  • 1
  • 3
  • 8
  • It looks like you are connecting to a networking device, provide as much information as possible aswell as the code that is producing the behaviour so that people can help you. – Georgi Rangelov Jun 11 '15 at 07:27
  • It is a PaloAlto Networks PanOS 6.0.7 FW device. It's problematic to show the code for this is a closed project, but let's assume this is a simple usage of creating new expect object, sending commands and matching the return traffic with the "-re" and regex parameters. – user116969 Jun 11 '15 at 10:41

1 Answers1

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
Georgi Rangelov
  • 335
  • 1
  • 11