title: Python communicate() with NMap
body: <p>My Code:</p>
  
  <pre><code>#!/usr/bin/python
  
  ## test communicate()
  
  # Import the module
  import subprocess
  
  # Ask the user for input
  host = raw_input("Enter a host to map: ")   
  
  # Set up the echo command and direct the output to a pipe
  p1 = subprocess.Popen(['nmap', '-T0', '-F', host], stdout=subprocess.PIPE)
  
  # Run the command
  output = p1.communicate()[0]
  
  print output
  </code></pre>
  
  <p>When I enter the host it doesn't give me any output and I can see multiple instances of nmap running with different PIDs in processes so it actually executes command.</p>
  
  <p>When I Z^ it says: [n+1]+  Stopped ./sample.py  So nmap is actually running n+1 times without printing any output.</p>
  
  <p>It works perfectly well with ping and traceroute like this:</p>
  
  <pre><code># Set up the echo command and direct the output to a pipe
  p1 = subprocess.Popen(['ping', '-c 2', host], stdout=subprocess.PIPE)
  p1 = subprocess.Popen(['traceroute', host], stdout=subprocess.PIPE)
  </code></pre>
  
  <p>It also works without nmap [options] like nmap google.com</p>
  
  <pre><code>p1 = subprocess.Popen(['nmap', host], stdout=subprocess.PIPE)
  </code></pre>
  
  <p>My Question:</p>
  
  <p>Is it related to Python or NMap? Is there anything wrong with this code or am I missing something?</p>