Created
November 27, 2016 01:33
-
-
Save zikrillah/0f637b973655cc0b5e7ed47b47670d15 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 ipaddress | |
from subprocess import Popen, PIPE | |
net4 = ipaddress.ip_network('10.1.1.0/24') | |
for x in net4.hosts(): | |
x = str(x) | |
hostup = Popen(["ping", "-c1", x], stdout=PIPE) | |
output = hostup.communicate()[0] | |
val1 = hostup.returncode | |
if val1 == 0: | |
print(x, "active") | |
else: | |
print(x, "inactive") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment