It look like a carriage return vs newline issue.
Your active terminal might not be matching the remote system and some automatic translation might be wrong. You can compare both system using the stty(1) command.
From the Expect documentation:
In this case, when you press return, it will be translated to a newline. If Expect then passes that to a program which sets its terminal to raw mode (like telnet), there is going to be a problem, as the program expects a true return.
Rather than manually replacing newlines with returns, the solution is to use the command "stty raw", which will stop the translation. Note, however, that this means that you will no longer get the cooked line-editing features.
I suggest you try replacing the \r
with \n
in your code. If that still doesn't work, it might need both \r\n
to work. If it still doesn't work you'll have to troubleshoot the terminal mode of both system and what happen to the carriage returns and newlines as they go back and forth.
Also, this assume you have the right passwords of course! ;)