Python & nmap
^Bart
gabriele1NOSPAM at hotmail.com
Wed May 18 17:52:05 EDT 2022
Hi guys,
i need to copy some files from a Debian client to all linux embedded
clients.
I know the linux commands like:
# scp "my_file" root at 192.168.205.x/my_directory
But... I have to upload 100 devices, I have a lan and a dhcp server just
for this work and I'd like to make a script by Python which can:
1) To scan the lan
2) To find which ips are "ready"
3) To send files to all of the "ready" clients
4) After I see on the display of these clients the successfully update I
remove from the lan them and I put them to the box to send them to our
customers.
I found https://pypi.org/project/python-nmap/ and I followed the line
"To check the network status" but... it doesn't work.
THE INPUT
-------------------------------------------------------------------------
import nmap
nm.scan(hosts='192.168.205.0/24', arguments='-n -sP -PE -PA21,23,80,3389')
hosts_list = [(x, nm[x]['status']['state']) for x in nm.all_hosts()]
for host, status in hosts_list:
print('{0}:{1}'.host)
THE OUTPUT
---------------------------------------------------------------------
Traceback (most recent call last):
File "/home/gabriele/Documenti/Python/nmap.py", line 1, in <module>
import nmap
File "/home/gabriele/Documenti/Python/nmap.py", line 2, in <module>
nm.scan(hosts='192.168.205.0/24', arguments='-n -sP -PE
-PA21,23,80,3389')
NameError: name 'nm' is not defined
Regards.
^Bart
More information about the Python-list
mailing list