Using expect
and password auto-login to remote with ssh, when resizing the window, stty size
report old size. Cause commands like vim
and less
mess up.
Asked
Active
Viewed 574 times
2

Kamil Maciorowski
- 21,864

user2204107
- 141
1 Answers
7
after a long time of search and test, finally find out it's expect
that cause the issue, by default expect will not forward WINCH signal, this can fix by trap command like this
trap {
#fetch rows and cols from controlling terminal
#note [] is tcl way of call and here the stty is expect's not system's which not support "stty rows" to query rows
set rows [stty rows]
set cols [stty columns]
#send "echo size changed to $rows $cols\r"
#according to the man page, the variable spawn_out(slave,name) is set to the name of the pty slave device
stty rows $rows columns $cols < $spawn_out(slave,name)
} WINCH
after add this at begining of my expect file, every thing works fine.
thanks Anish Sneh from https://askubuntu.com/a/672919/1384831
want to answer at How to solve the issue that a Terminal screen is messed up? (usually after a resizing) but it is protected, so post a new question. wish it will save some others time.

user2204107
- 141
expect
. The other question does not mentionexpect
at all. IMO in such case asking a separate question is justified. – Kamil Maciorowski Sep 09 '21 at 15:48ssh
directly withoutexpect
and finally realize it's expect's issue. – user2204107 Sep 10 '21 at 02:00