Last active
November 27, 2016 01:45
-
-
Save zikrillah/c657f2d64853dd8c8f49818aa3d76928 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 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