In my company we use expect
to automate tasks, when ssh
'ing into other systems. All our legacy systems run ISO-8859-1 character encoding, while our desktop systems run UTF-8 encoding. Which of course poses certain challenges when ssh
'ing from one of our desktops into our legacy systems.
This is easily solved by removing the SendEnv
line in /etc/ssh/ssh_config
and setting the Gnome terminal character encoding to ISO-8859-1 just before starting the ssh
session. This works fine when doing it manually from the command prompt or from a bash
script. But when doing it from inside an expect
script it fails. It seems like the character encoding either isn't handled at all or is handled incorrectly from within expect
, which results in mangled characters when we enter special characters.
Bare bones bash
script that works:
#!/bin/bash
ssh user@server
Bare bones expect
script that produces the error:
#!/usr/bin/expect --
spawn ssh user@server
interact
The Gnome terminal character encoding has been manually set correctly before executing the two scripts. These two scripts should work identically, by ssh
'ing into the server and letting the user enter the password. But the bash
script handles character encoding correctly, while the expect
script produces mangled special characters.
I assume I'm missing something obvious, but I can't figure out what it is I'm missing.
Edit: We have already tried luit
, which doesn't help. It only results in differently mangled characters.