PING'ing an IP (works if IP exists, doesn't if not)

Hi

I need somehow to find out, if my application is running in the local network or remotely over the internet.
I figured out I could just PING an IP that is in my local network and if that IP is available check for a website on that IP (to not mix up with a wrong local network).

I tried it like this:

set we_pingOutput to (do shell script "ping -o -t 1 " & we_lokalIP)

This works fine if the IP exists, but gives no output if the IP doesn’t exist.

How could I make this happen?

How about wrapping it in a try command:

try
	set we_pingOutput to (do shell script "ping -o -t 1 " & we_lokalIP)
on error
	set we_pingOutput to "Some text"
end try

Then if the IP doesn’t exists then, the we_pingOutput variable will be set to what ever you want.

Thanks this worked :slight_smile: