I wanted to automate ssh logins. After some research, it seemed like tcl/expect was the route to go.
However, my issue is that when interact takes over my terminal, stuff doesn't work as expected (pun not intended).
For example, if I resize the terminal, it does not "take". Also, sometimes the interact is not responsive, and sometimes it just hangs for no reason. I have included my code below. My question for the code is, am I missing something?
Also, is there a better way to do this (with another scripting language?) I need the terminal to be very responsive, and no different than if I had manually typed ssh on the console.
proc Login {username server password} {
set prompt "(%|>|\#|\\\$) $"
spawn /usr/bin/ssh $username@$server
expect {
-re "Are you sure you want to continue connecting (yes/no)?" {
exp_send "yes\r"
exp_continue
#continue to match statements within this expect {}
}
-nocase "password: " {
exp_send "$password\r"
interact
}
}
}