I am looking for an easy way to check if an IP is alive that will not crash my program.
I tried this code and it gives me an error on the output stating that the IP cannot be found , but if I go to CMD , it works perfectly, Any Ideas ?
B4X:
sub Pings(apd As String)
Dim sh2 As Shell
sh2.Initialize("sh2","ping",Array(apd&" -w 1000 -n 1"))
sh2.Run(1000)
End Sub
Sub sh2_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
Log("exit code "&ExitCode)
Log("out "&StdOut)
Log("error "&StdErr)
Log("Success "&Success)
End Sub
each parameter is its own separate string in the passed array. you were passing everything as 1 string. not only that, but any parameters that take a value (eg, -c 5) requires 2 strings (1 for the switch and 1 for the value!!!)
so, to ping apd and set the count to 5, you need array( apd, "n", "5" )
each parameter is its own separate string in the passed array. you were passing everything as 1 string. not only that, but any parameters that take a value (eg, -c 5) requires 2 strings (1 for the switch and 1 for the value!!!)
so, to ping apd and set the count to 5, you need array( apd, "n", "5" )