0

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.

3

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.

2
  • Your issue and your answer are specific to expect. The other question does not mention expect at all. IMO in such case asking a separate question is justified. Sep 9 at 15:48
  • many people (at least me) don't realize it's expect's problem, that question is so hot and is the first search result of "remote shell resize issue" from google. I have tried all answers there without any luck and almost give up. recently, in some cases, I use ssh directly without expect and finally realize it's expect's issue. Sep 10 at 2:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.