Skip to content
Advertisement

TCL Expect is injecting an extra null character to stdout

It seems that expect is adding an extra null character or something to stdout. For example:

JavaScript

What is this extra character and how do I get rid of it?

Advertisement

Answer

It’s not a null character. You can use a tool like xxd to see exactly what output expect is producing:

JavaScript

This shows that you are getting a standard CR/LF end-of-line terminator. I’m guessing this is being produced because the stdout of your echo process is attached to a tty device, which often involves additional filtering to modify end-of-line characters and so forth (see stty for details).

You can disable this behavior by putting the tty in raw mode, like this:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement