This question already has an answer here:
- Calling an external command in Python 36 answers
I want execute netcat command from my python script, so I use the 'subprocess.Popen', but the problem is that the output of this command is directly printed in may shell console, i want o get him in a variable , so i can do some modification before printing it.
res = subprocess.Popen("nc -v 192.168.1.1 25", stdout=subprocess.PIPE, stderr=None, shell=True)
#output = res.communicate()
#output = str(output)
#print output
stderr
? It is unlikely thatnc
would print directly to the terminal unless to prompt you for the password – J.F. Sebastian Mar 13 '14 at 17:21