unix and linux
[팁] expect 이용시 창 크기가 바뀌어도 터미널에서 반영못한 현상을 해결
'김용환'
2014. 5. 20. 16:10
회사 지인이 알려준 좋은 팁 - expect 이용시 창 크기가 바뀌어도 터미널에서 반영못한 현상을 해결
http://ubuntuforums.org/showthread.php?t=865420
아래 코드를 #!/usr/bin/env expect 밑에 추가하면 됨.
Code:
trap { set rows [stty rows] set cols [stty columns] stty rows $rows columns $cols < $spawn_out(slave,name) } WINCH
실제 예
Code:
#!/usr/bin/env expect
#trap sigwinch and pass it to the child we spawned
trap {
set rows [stty rows]
set cols [stty columns]
stty rows $rows columns $cols < $spawn_out(slave,name)
} WINCH
set username yourUserNameHere
set pass yourPasswordHere
set host theIpAddressToConnectTo
spawn ssh ${username}@${host}
expect -re "password:"
send "${pass}\r"
expect -re "$"
# now interact with the session
interact