-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathipcheck.py
More file actions
47 lines (23 loc) · 1.01 KB
/
Copy pathipcheck.py
File metadata and controls
47 lines (23 loc) · 1.01 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
#Imports subprocess (used for async functionality)
import subprocess
#Asks user for input (can be dragged from desktop)
fields = ['IP', 'Response']
plist = input("Paste exact file path of ip list: ")
filename = input("What do you want the name of the output file to be?")
with open(plist, 'r') as fileobj:
def ping(ip):
#Pings the ip once, change the "1" to "2" if MAC adress is not resolving, may make it slower
ping_reply = subprocess.run(["ping","-n","1", ip],stderr=subprocess.PIPE, stdout=subprocess.PIPE)
result =""
print (".", end='')
if ping_reply.returncode == 0:
#ping will return 0 success if destination is unreachable
if ("unreachable" in str(ping_reply.stdout)):
result = ("\n Offline%s" % ip)
else:
result= ("\n Online %s" % ip)
elif ping_reply.returncode == 1:
result= ("\n No response %s" % ip)
return result
for ip in fileobj:
print(ping(ip.strip()))