On 2022-05-18, ^Bart <gabriele1nos...@hotmail.com> wrote: > 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
You forgot the second line (after 'import nmap' and before 'nm.scan()'): nm = nmap.PortScanner() -- https://mail.python.org/mailman/listinfo/python-list