-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_ip.py
More file actions
executable file
·28 lines (26 loc) · 859 Bytes
/
Copy pathtest_ip.py
File metadata and controls
executable file
·28 lines (26 loc) · 859 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
#!/usr/bin/python3
import os
import sys
import subprocess
for k in range(1):
outstr = ''
for i in range(254):
ip="192.168.5.%d" %(i)
#print(ip)
rep = os.system('fping -t 100 -q -c 1 ' + ip + ' > /dev/null 2>&1')
if rep == 0:
# arp list
p = subprocess.Popen(['arp', '-n'], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
out, err = p.communicate()
try:
arp = [x for x in out.split('\n') if ip in x][0]
#print(arp)
except:
#print(out)
#print("\n")
arp = "None None Not:Found"
# this will print out the interface name
outstr += " Host Up "+ip+" MAC = " + ' '.join(arp.split()).split()[2] + "\n"
# print("Host Up ",ip)
os.system('clear')
print(outstr)