Skip to content

Instantly share code, notes, and snippets.

@sonnyksimon
Created September 7, 2020 11:47
Show Gist options
  • Save sonnyksimon/878c80d96a3cb0670015053f54648932 to your computer and use it in GitHub Desktop.
Save sonnyksimon/878c80d96a3cb0670015053f54648932 to your computer and use it in GitHub Desktop.
import platform
import subprocess
def ping(host):
""" Returns True if host (str) responds to a ping request. """
if platform.system().lower() == 'windows':
param = '-n'
else:
param = '-c'
command = ['ping', param, '1', host]
return subprocess.call(command) == 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment