python subprocess.popen get into an infinite loop
Question: I'm trying to run the folowing command on a sub process and collecting the
output.

    
    
    nmap -n -PN -sT -T4  -p 445,139 10.11.1.0/24 --exclude matrix
    

this command return an error which is fine by me.

The problem is when i'm doing this from python like this:

    
    
    import subprocess
    nmap_process = subprocess.Popen(command, stdout=subprocess.PIPE,stderr=subprocess.PIPE)        
    output,errOutput=nmap_process.communicate()
    

the process hang.  
if i don't use the stderr param,the first error line of namp is printed in an
infinite loop

does anybody have any segesstion about how to handle this?


Answer: 
    import subprocess
    cmd = "nmap -n -PN -sT -T4  -p 445,139 10.11.1.0/24 --exclude matrix"
    pro = subprocess.Popen(cmd, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
    pro.communicate() #[0] is stdout [1] is stderr :P
    

self.nmap_process.communicate() seems to be your problem. Are you creating
this inside a class? Can we see more of the code? Also when I run a nmap
stderr cmd in the same code I don't get a hang in my code, and It doesn't
infinite loop.

