Skip to content

Instantly share code, notes, and snippets.

@zikrillah
Last active November 27, 2016 01:45
Show Gist options
  • Save zikrillah/c657f2d64853dd8c8f49818aa3d76928 to your computer and use it in GitHub Desktop.
Save zikrillah/c657f2d64853dd8c8f49818aa3d76928 to your computer and use it in GitHub Desktop.
import subprocess
import os
with open(os.devnull, "wb") as limbo:
for n in xrange(1, 10):
ip="10.1.1.{0}".format(n)
result=subprocess.Popen(["ping", "-c", "1", "-n", "-W", "2", ip],
stdout=limbo, stderr=limbo).wait()
if result:
print ip, "inactive"
else:
print ip, "active"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment