connection state (General questions)
How do I know if a server has timed out?
In my example below when if a server is down the script errors when it hits sshConnection.connect. Is there a way to detect timeout and not connect to that server?
[code]
Option Explicit
Dim sshConnection
Dim mExecuted, gastrDomainName, intIndex, strDomainName, gstrDomainName
Dim strPercentUsed, strPercentUsed2, strFindPercent, strFindPercent2
Set sshConnection = WScript.CreateObject( WeOnlyDo.wodTelnetDLXCom.1 )
strDomainName= myserver1, myserver2
gastrDomainName = Split(strDomainName, , )
For intIndex = 0 To UBound(gastrDomainName)
gstrDomainName = gastrDomainName(intIndex)
sshConnection.Timeout = 10
sshConnection.Protocol = 2
sshConnection.Blocking = 1
sshConnection.Port = 22
sshConnection.HostName = Trim(gstrDomainName)
sshConnection.Login = user1
sshConnection.Password = password1
sshConnection.Connect
WScript.Echo sshConnection.State
sshConnection.WaitFor ( regex:[$ #>:] $ )
sshConnection.DataReady = 0
mExecuted = sshConnection.Execute( df -h / + vbLf, $ )
wscript.echo mExecuted
strFindPercent = ((InStrRev(gstrLogMsg, ,Len(gstrLogMsg))) -3)
strPercentUsed = Trim(Mid(gstrLogMsg,strFindPercent,3))
mExecuted = sshConnection.Execute( df -h /toptech_prj + vbLf, $ )
wscript.echo mExecuted
strFindPercent2 = ((InStrRev(gstrLogMsg2, ,Len(gstrLogMsg2))) -3)
strPercentUsed2 = Trim(Mid(gstrLogMsg2,strFindPercent2,3))
wscript.echo gstrDomainName & : Root Partition: & strPercentUsed & & vbCrLf & /toptech_prj: & strPercentUsed2 & & vbCrLf
sshConnection.Disconnect
Next
Set sshConnection = Nothing[/code]