Check if remote host is up in Python

user140736 picture user140736 · Mar 29, 2010 · Viewed 38.8k times · Source

How would I check if the remote host is up without having a port number? Is there any other way I could check other then using regular ping.

There is a possibility that the remote host might drop ping packets

Answer

jmunsch picture jmunsch · Nov 29, 2016

This worked fine for me:

HOST_UP  = True if os.system("ping -c 1 " + SOMEHOST) is 0 else False