How can know if a specific computer on a network is awake ?

Hi,

If I have 3 machine: computerA, computerB and computerC. Is there a way, by script, to know if a specific machine is awake ? If yes … how do I do that ?

Thanks in advance.

Robert

Model: iMac Intel (10.6.2) + iMac G5 (10.4.11)
AppleScript: 2.3 + 2.1.1
Browser: Safari 531.9
Operating System: Mac OS X (10.6)

Assuming you know their IP Addresses, you could ping them:

do shell script "ping -c 2 10.0.1.1"

The -c 2 means ping twice.

Thank you Adam …

I tried it but do not know what to do with the result in order to use it as a variable in the script. How can I interpret the result of the shell script to say if the selected address is active ?

If the connection is active I got this result:

"PING 10.0.1.3 (10.0.1.3): 56 data bytes
64 bytes from 10.0.1.3: icmp_seq=0 ttl=64 time=0.044 ms
64 bytes from 10.0.1.3: icmp_seq=1 ttl=64 time=0.063 ms

— 10.0.1.3 ping statistics —
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.044/0.053/0.063/0.010 ms"

This seems to mean that the connection is active. When not the script returns an error message. How can I use these result to define: «active» or «not active» ?

Thanks in advance.

on subping(valip)--string
	try
		do shell script "ping -c 2 " & valip
		return true
	on error
		return false
	end try
end subping

Thank you. It will do the job perfectly !! It even works with the “name.local” format.

:slight_smile:

Hi Richard,

Why would a handler detect a “sleeping computer” as “awake” :confused: :/:confused: ? Is there network conditions when it is possible to get this result ?

You script gives the same result as the WakeOnLan utility. Both see my iMac Intel as awake even if it is deeply sleeping.

Regards.

Robert

I don’t know about ping and sleeping Macs, I just gave you the ping/no ping script, from what Adam said.