Created
September 7, 2020 11:47
-
-
Save sonnyksimon/878c80d96a3cb0670015053f54648932 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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