How can I ping an IP adress in Julia?

question

#1

Hello,
I need a script to measure the ping time to another computer in Julia.
How can I do that?

All hints welcome!

Uwe


#2
julia> match(r"time=(.*)$", split(readstring(`ping -c 1 8.8.8.8`) , "\n", keep=false)[2])[1]
"5.153 ms"

Does that work?


#3

The OP didn’t respond so I will: yes, thanks. :slight_smile:


#4

I needed something a little more specific: to test all addresses on my subnet to see what was connected. So starting with your line, Avik, I looped and spawned to test the range without blocking on the addresses that responded:

for i in 1:254
    @spawn push!(a, [i, match(r"time=(.*)$", split(readstring(`ping -c 1 10.27.96.$i`),
                    "\n", keep=false)[2])[1]])
    print(i)
    sleep(0.1)
end;
print(a)```

Best,  Mark.