3

I am invoking nmap with the following command:

nmap -oX i.xml -p 1-1023 -r -T4 -d -d  

Doing this sends output to i.xml successfully. However, text is still printed on the command line in additional being redirected to i.xml. I would like the command to run silently on the command line, but to still write all of its output to my i.xml file. I tried using the -v0 argument, but using it results in neither my XML file nor the command line seeing any output.

How can I tell nmap to send its output only to my XML file?

Brighid McDonnell
  • 4,293
  • 4
  • 36
  • 61
user1486918
  • 31
  • 1
  • 2

2 Answers2

7

Have you tried redirecting stdout to the null device?

nmap -oX i.xml -p 1-1023 -r -T4 -d -d >/dev/null

On Windows, use NUL instead of /dev/null

Fred Sobotka
  • 5,252
  • 22
  • 32
  • I just attempted it. The xml file doesn't get made. – user1486918 Jun 27 '12 at 21:35
  • What version of Nmap are you running? This should work (and does on my installation) – bonsaiviking Jun 27 '12 at 22:06
  • It works for me as well, can you provide us information on your os and nmap version? – raz3r Jun 28 '12 at 10:36
  • Nmap version 5.51 and Windows 7 64bit. I feel I should also mention that I run nmap through python using the command os.system("nmap -oX i.xml -p 1-1023 -r -T4 -d -d") – user1486918 Jun 28 '12 at 13:22
  • 1
    Sorry, I'd assumed you were using Linux or UNIX. I've added a note on how to reference the null device on Windows. That should work from the Windows command line, but there may be complications when that is done inside of a Python call to os.system(), so you may need to use Python's stdout redirection options instead if you're still not getting the desired behavior. – Fred Sobotka Jun 28 '12 at 23:44
1

First, you didn't specified any target on your command line. Not sure what you intend to do Second, -oX i.xml will output to i.xml AND stdout To have results only on xml file (and not on stdout), add an extra -v0 parameter

Chris Chris
  • 352
  • 3
  • 10