Xojo Plugin
Xojo Plugin
Request a Pseudo-Terminal (PTY) over SSH
See more SSH Examples
Demonstrates the Chilkat Ssh.SendReqPty method, which requests a pseudo-terminal for a session channel. The arguments are the channel number, the terminal type, the character width and height, and the pixel width and height. It must be sent before the primary exec or shell request.
Background: A PTY makes the remote side behave as though a real terminal is attached, which matters for programs that draw screens, prompt for passwords, or colorize output — many refuse to run interactively without one. The terminal type (such as
xterm) tells the remote program what escape sequences it may use. Pixel dimensions are commonly 0, meaning unspecified.Chilkat Xojo Plugin Downloads
Dim success As Boolean
success = False
// Demonstrates the Ssh.SendReqPty method, which requests a pseudo-terminal for a session
// channel. The 1st argument is the channel number, the 2nd is the terminal type, the 3rd and
// 4th are the character width and height, and the 5th and 6th are the pixel width and height.
// It must be sent before the primary exec or shell request.
Dim ssh As New Chilkat.Ssh
Dim sshPort As Int32
sshPort = 22
success = ssh.Connect("ssh.example.com",sshPort)
If (success = False) Then
System.DebugLog(ssh.LastErrorText)
Return
End If
// 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.
Dim password As String
password = "mySshPassword"
success = ssh.AuthenticatePw("mySshLogin",password)
If (success = False) Then
System.DebugLog(ssh.LastErrorText)
Return
End If
// Open a session channel. A negative return value indicates failure.
Dim channelNum As Int32
channelNum = ssh.OpenSessionChannel()
If (channelNum < 0) Then
System.DebugLog(ssh.LastErrorText)
Return
End If
// Request an 80x24 xterm. Pixel dimensions of 0 mean unspecified.
Dim termType As String
termType = "xterm"
Dim widthInChars As Int32
widthInChars = 80
Dim heightInChars As Int32
heightInChars = 24
Dim widthInPixels As Int32
widthInPixels = 0
Dim heightInPixels As Int32
heightInPixels = 0
success = ssh.SendReqPty(channelNum,termType,widthInChars,heightInChars,widthInPixels,heightInPixels)
If (success = False) Then
System.DebugLog(ssh.LastErrorText)
Return
End If
// Start the shell now that the PTY is allocated.
success = ssh.SendReqShell(channelNum)
If (success = False) Then
System.DebugLog(ssh.LastErrorText)
Return
End If
ssh.Disconnect