How can I ping an IP adress in Julia?

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

All hints welcome!

Uwe

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

Does that work?

1 Like

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

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.
1 Like