-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPythonPinger.py
More file actions
33 lines (23 loc) · 757 Bytes
/
PythonPinger.py
File metadata and controls
33 lines (23 loc) · 757 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
"""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 your python pinger"
#repalce "address.txt" with whatever textfile has all your IPs
file = open("address.txt", "r")
addressList = []
for line in file:
addressList.append(line)
number = len(addressList)
for i in range (0,number):
hostname = addressList[i]
response = os.system("ping -n 4 " + hostname)
if response == 0:
pingstatus = hostname + ": Network Active"
else:
pingstatus = hostname + ": Network Error"
print pingstatus
pause = raw_input("Press enter to exit")
file.close()