### Test Host Online

This is a possible Shell Solution to test if a Host is Online. It requires the jShell library.
There might be other solutions, but so far this solution works fine.
'Set a global var:
' Private HostOnline As Boolean
'Example call (do not use prefix):
' IPPing("192.168.0.88")
`Sub IPPing(ipaddress As String)
Dim shl As Shell
Dim lstParams As List: lstParams.Initialize
Try
Dim os As String = GetSystemProperty("os.name", "").ToLowerCase
If os.Contains("win") Then
'Windows
lstParams.Add("-n")
Else
'Linux and Mac
lstParams.Add("-c")
End If
lstParams.Add("1")
lstParams.Add(ipaddress)
shl.Initialize("shl", "ping", lstParams)
shl.WorkingDirectory = File.DirApp
shl.Run(-1)
Catch
Log(LastException.Message)
End Try
End Sub`
`Sub shl_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
'Checking stdout string; this depends on the OS system language used. This can be checked with System.getProperty("user.language");
Dim userlanguage As String = GetSystemProperty("user.language", "")
Select userlanguage.ToLowerCase
Case "de"
HostOnline = StdOut.ToLowerCase.Contains("nicht") = False
Case "en"
HostOnline = (StdOut.ToLowerCase.Contains("request timed out") = False) Or _
(StdOut.ToLowerCase.Contains("unreachable") = False)
End Select
If HostOnline Then
Log("Host is reachable.")
Else
Log("Host is NOT reachable.")
End If
ExitApplication
End Sub`

Changed: , Category: Internet, File: T6C203M1493.htm, ID: 1493