Visual FoxPro
Visual FoxPro
Notify the SSH Server of a Terminal Resize
See more SSH Examples
Demonstrates the Chilkat Ssh.SendReqWindowChange method, which tells the server that the terminal dimensions changed. The arguments are the channel number, the new character width and height, and the pixel width and height. It may be sent any time after the PTY is allocated.
Background: When a user resizes a terminal window, full-screen remote programs such as
vi, top, or less need to know the new size or they will keep drawing at the old dimensions. This request delivers that update, causing the server to signal the remote process (SIGWINCH on Unix) so it can redraw correctly.Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loSsh
LOCAL lnSshPort
LOCAL lcPassword
LOCAL lnChannelNum
LOCAL lnNewWidthInChars
LOCAL lnNewHeightInRows
LOCAL lnPixWidth
LOCAL lnPixHeight
lnSuccess = 0
* Demonstrates the Ssh.SendReqWindowChange method, which notifies the server that the terminal
* dimensions changed. The 1st argument is the channel number, the 2nd and 3rd are the new
* character width and height, and the 4th and 5th are the pixel width and height.
loSsh = CreateObject('Chilkat.Ssh')
lnSshPort = 22
lnSuccess = loSsh.Connect("ssh.example.com",lnSshPort)
IF (lnSuccess = 0) THEN
? loSsh.LastErrorText
RELEASE loSsh
CANCEL
ENDIF
* Normally you would not hard-code the password in source. You should instead obtain it
* from an interactive prompt, environment variable, or a secrets vault.
lcPassword = "mySshPassword"
lnSuccess = loSsh.AuthenticatePw("mySshLogin",lcPassword)
IF (lnSuccess = 0) THEN
? loSsh.LastErrorText
RELEASE loSsh
CANCEL
ENDIF
* Open a session channel. A negative return value indicates failure.
lnChannelNum = loSsh.OpenSessionChannel()
IF (lnChannelNum < 0) THEN
? loSsh.LastErrorText
RELEASE loSsh
CANCEL
ENDIF
* Allocate a PTY and start a shell.
lnSuccess = loSsh.SendReqPty(lnChannelNum,"xterm",80,24,0,0)
IF (lnSuccess = 0) THEN
? loSsh.LastErrorText
RELEASE loSsh
CANCEL
ENDIF
lnSuccess = loSsh.SendReqShell(lnChannelNum)
IF (lnSuccess = 0) THEN
? loSsh.LastErrorText
RELEASE loSsh
CANCEL
ENDIF
* The user resized the terminal window -- tell the server the new dimensions.
lnNewWidthInChars = 132
lnNewHeightInRows = 43
lnPixWidth = 0
lnPixHeight = 0
lnSuccess = loSsh.SendReqWindowChange(lnChannelNum,lnNewWidthInChars,lnNewHeightInRows,lnPixWidth,lnPixHeight)
IF (lnSuccess = 0) THEN
? loSsh.LastErrorText
RELEASE loSsh
CANCEL
ENDIF
? "Window change sent."
loSsh.Disconnect()
RELEASE loSsh