bogdanc Active Member Licensed User Longtime User Feb 7, 2017 #1 Hi All! While a go I asked how to ping server and get respond. I've got some answer but it only tells me that server is responding. How to get similar thing as it on win shell cmd with the number of packets received or lost and time of respond? Code: Copy Sub Ping(ipaddress As String) Log("started") Dim shl As Shell Dim lstParams As List: lstParams.Initialize Try Dim os As String = GetSystemProperty("os.name", "").ToLowerCase If os.Contains("win") Then Log("Windows") '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 Thank you for any help in advance.
Hi All! While a go I asked how to ping server and get respond. I've got some answer but it only tells me that server is responding. How to get similar thing as it on win shell cmd with the number of packets received or lost and time of respond? Code: Copy Sub Ping(ipaddress As String) Log("started") Dim shl As Shell Dim lstParams As List: lstParams.Initialize Try Dim os As String = GetSystemProperty("os.name", "").ToLowerCase If os.Contains("win") Then Log("Windows") '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 Thank you for any help in advance.
udg Expert Licensed User Longtime User Feb 8, 2017 #2 Are you looking for the "feedback" from a successful ping command? Did you add something like the following to your code? Code: Copy Sub shl_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut AsString, StdErr AsString) If Success AND ExitCode = 0 Then Log("Success") Log(StdOut) Else Log("Error: " & StdErr) EndIf ExitApplication End Sub Are you aware that many installations don't allow reply to a ping command? udg Upvote 0
Are you looking for the "feedback" from a successful ping command? Did you add something like the following to your code? Code: Copy Sub shl_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut AsString, StdErr AsString) If Success AND ExitCode = 0 Then Log("Success") Log(StdOut) Else Log("Error: " & StdErr) EndIf ExitApplication End Sub Are you aware that many installations don't allow reply to a ping command? udg
bogdanc Active Member Licensed User Longtime User Feb 8, 2017 #3 Thank You for You replay! Yes. I need to have a feedback from shell. No i'm getting some output. Code: Copy ..... Packets: Sent = 1, Received = 1, Lost = 0 (0% loss), Minimum = 3ms, Maximum = 3ms, Average = 3ms ..... 1) is it a way to strip the info the get time and packet's losts? put this to the variable and search for: Average = and cut it to display rest of string. 2) Second how to ping 4 ips on the same time? Code: Copy lstParams.Add(ipaddress1) lstParams.Add(ipaddress2) . . . lstParams.Add(ipaddressN) Upvote 0
Thank You for You replay! Yes. I need to have a feedback from shell. No i'm getting some output. Code: Copy ..... Packets: Sent = 1, Received = 1, Lost = 0 (0% loss), Minimum = 3ms, Maximum = 3ms, Average = 3ms ..... 1) is it a way to strip the info the get time and packet's losts? put this to the variable and search for: Average = and cut it to display rest of string. 2) Second how to ping 4 ips on the same time? Code: Copy lstParams.Add(ipaddress1) lstParams.Add(ipaddress2) . . . lstParams.Add(ipaddressN)
udg Expert Licensed User Longtime User Feb 8, 2017 #4 Hi, have a look at RegEx for a powerful method to extract info from a non-structured text (i.e. your StdOut as retuned by jshell after executing the ping command). AFAIK, ping command works on a single address at time. You could list a few addresses in a global list, process on item at time (the top one), remove it an so on while you ha ve items in the list. Upvote 0
Hi, have a look at RegEx for a powerful method to extract info from a non-structured text (i.e. your StdOut as retuned by jshell after executing the ping command). AFAIK, ping command works on a single address at time. You could list a few addresses in a global list, process on item at time (the top one), remove it an so on while you ha ve items in the list.
I inakigarm Well-Known Member Licensed User Longtime User Feb 8, 2017 #5 Pinging at several IP's; see jShellQueue at https://www.b4x.com/android/forum/threads/jshellqueue.58315/#post-367286 Upvote 0
Pinging at several IP's; see jShellQueue at https://www.b4x.com/android/forum/threads/jshellqueue.58315/#post-367286