-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPythonPinger-3.py
More file actions
34 lines (24 loc) · 956 Bytes
/
PythonPinger-3.py
File metadata and controls
34 lines (24 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""Python script contracted by Spencer McDonald to ping multiple devices
Reads from text file in same directory
make sure each new ip address is on a new line
"""
import subprocess
import os
print "Hello, welcome to Python Pinger"
#repalce "address.txt" with whatever textfile has all your IPs
#MAKE SURE EACH ADDRESS IS ONE A NEW LINE
addressList = []
with open("address.txt") as f:
addressList = f.readlines()
addressList = [line.rstrip('\n') for line in open("address.txt")]
number = len(addressList)
with open(os.devnull, "wb") as limbo:
for n in range(0, number):
ip = addressList[n]
result=subprocess.Popen(["ping", "-n", "1", "-w", "200", ip],
stdout=limbo, stderr=limbo).wait()
if result:
print ip, ":Inactive"
else:
print ip, ":Active"
pause = raw_input("Press enter to exit")