File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ import os
2
+ import platform
3
+ import re
4
+ import nmap
5
+ import json
6
+
7
+
8
+ rpi_ip_list = []
9
+ rpi_name_list = []
10
+
11
+
12
+ def pi_search ():
13
+ print ('Searching for RPi' )
14
+ print ("---------------------------" )
15
+
16
+ nm = nmap .PortScanner ()
17
+ nm .scan ('192.168.1.0/24' ,arguments = '-sP' ) #Note that I tested with -sP to save time
18
+ for host in nm .all_hosts ():
19
+ #print(host + " "+nm[host].hostname())
20
+ item = nm [host ]['addresses' ]
21
+ if nm [host ].hostname () == 'raspberrypi' :
22
+ print (nm [host ].hostname (),item )
23
+
24
+ print ("---------------------------" )
25
+
26
+ def run ():
27
+ pi_search ()
28
+
29
+ if rpi_ip_list == []:
30
+ pi_search ()
31
+
32
+ def main ():
33
+
34
+ if rpi_ip_list == []:
35
+ print ('Running nmap' )
36
+ pi_search ()
37
+ print ("HOST_VARS" )
38
+
39
+
40
+ if __name__ == "__main__" :
41
+ main ()
You can’t perform that action at this time.
0 commit comments