(VBScript) Check SSH Connection (IsConnected)
Demonstrates how to check to see if the connection to the SSH server exists.
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Ssh")
set ssh = CreateObject("Chilkat.Ssh")
' Connect to an SSH server:
success = ssh.Connect("192.168.1.209",22)
If (success <> 1) Then
outFile.WriteLine(ssh.LastErrorText)
WScript.Quit
End If
' Is the last known state "connected"?
connected = ssh.IsConnected
If (connected = 1) Then
' Verify for sure by sending an ignore message.
connected = ssh.SendIgnore()
End If
outFile.WriteLine("connected = " & connected)
' Disconnect.
ssh.Disconnect
' Am I still connected?
connected = ssh.IsConnected
outFile.WriteLine("connected = " & connected)
outFile.Close
|