Visual FoxPro
Visual FoxPro
Clear Accumulated SSH TTY Modes
See more SSH Examples
Demonstrates the Chilkat Ssh.ClearTtyModes method, which clears all TTY modes previously added with SetTtyMode. It takes no arguments. The next SendReqPty will not include the cleared modes.
Background: Because TTY modes accumulate on the
Ssh object, they would otherwise carry over into every later PTY request on that object. ClearTtyModes resets that state — useful when one Ssh object opens several channels and each needs different terminal settings, or when you want a PTY created with the server's defaults.Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loSsh
LOCAL lnSshPort
LOCAL lcPassword
LOCAL lnChannelNum
lnSuccess = 0
* Demonstrates the Ssh.ClearTtyModes method, which clears all TTY modes previously added with
* SetTtyMode. It takes no arguments.
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
* Add a TTY mode, then discard it before requesting the PTY.
lnSuccess = loSsh.SetTtyMode("ECHO",0)
IF (lnSuccess = 0) THEN
? loSsh.LastErrorText
RELEASE loSsh
CANCEL
ENDIF
* Clear the accumulated TTY modes. The next SendReqPty will not include them.
loSsh.ClearTtyModes()
* Open a session channel. A negative return value indicates failure.
lnChannelNum = loSsh.OpenSessionChannel()
IF (lnChannelNum < 0) THEN
? loSsh.LastErrorText
RELEASE loSsh
CANCEL
ENDIF
* This PTY request carries no custom TTY modes.
lnSuccess = loSsh.SendReqPty(lnChannelNum,"xterm",80,24,0,0)
IF (lnSuccess = 0) THEN
? loSsh.LastErrorText
RELEASE loSsh
CANCEL
ENDIF
loSsh.Disconnect()
RELEASE loSsh