blindsnowmobile blindsnowmobile - 1 month ago 20
Bash Question

Expect script not sending new line correctly

I'm using expect to respond to a network service. However, I've noticed in Wireshark, when I do the following:

send "mystring\r\n"

it gets translated on the wire to:


I've tried setting
stty raw
, and various combinations of
, as well as sending ASCII codes from within expect. Expect seems to be translating any of these combinations to
. The problem is the server seems to require a
in order to accept the input. I've been able to determine this, because when I use "interact" from within expect, and then type a
(control-v enter) from the shell, Wireshark sees a string of:

"mystring \r\n"

sent out over the wire, and the server processes the input correctly. Is there a way to properly send this combination through expect without the translation?


Are you doing the stty directly or by using set stty_init raw in the expect script? (expect's stty command operates on your terminal, not the pty.) You may also want to look at the -nottyinit option to spawn.