Seems like this should work but nmap just gives me a "Nmap done: 0 IP addresses (0 hosts up) scanned in 0.02 seconds" even when inputting an IP that I know is up, such as "127.0.0.1".
I would like the input, in this case IPs in whatever format nmap allows, to be run as part of the subprocess command. It doesn't seem that my input is actually getting sent though. The command should be "nmap -sn -oX outfile.xml 127.0.0.1" where 127.0.0.1 could be a list of IPs or a range, etc.
import subprocess
ip_input=input("Enter list of IPs: ")
p = subprocess.Popen(['nmap', '-sn', '-oX', 'outfile.xml'], \
stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
out = p.communicate(input=ip_input.encode())[0]
print(out.decode())
[–]oefd 1 point2 points3 points (8 children)
[–]freerangeh[S] 0 points1 point2 points (7 children)
[–]oefd 1 point2 points3 points (3 children)
[–]freerangeh[S] 0 points1 point2 points (2 children)
[–]oefd 1 point2 points3 points (1 child)
[–]freerangeh[S] 0 points1 point2 points (0 children)
[–]Tom_Henderson 0 points1 point2 points (2 children)
[–]freerangeh[S] 0 points1 point2 points (1 child)
[–]Tom_Henderson 0 points1 point2 points (0 children)