The problem is that the process is not being started. The object is created, but there is and was no process.
If I put a time.sleep() before the os.kill statement, I lose control. The process does start, but it isn’t killed. Additionally, my stdout is lost. Anything I type does not appear (I guess it’s also going to null). I have to close the terminal, open a new one, and manually kill the process (starting python and issuing that exact command does the job, which is good to know)
airodump = subprocess.Popen('airodump-ng -w outputfile mon0',shell=True,stdout=open('/dev/null', 'w'), stderr=open('/dev/null', 'w'))
#time.sleep(5)
os.kill(airodump.pid, signal.SIGTERM) # airodump-ng
#airodump.wait()
print airodump
I’ve tried invoking the methods Popen.terminate(), Popen.kill(). I’m missing something with Popen….
Even when I put in a Popen.wait() before “print airodump” it just gets bypassed and the object address is printed. That little quirk is what has convinced me something is not right in my understanding of what’s going on.
You should try:
Notice I’ve replaced your string command with a list, dropped the shell=True and the stdout stuff. First shell=True makes everything harder to debug so you should try running this without it, but in order to do that you’ll need to use a list for your command not a string.
The more standard way to capture stdout/stderr and prevent them from going to screen is to use
stdout=subprocess.PIPE. If you still can’t get this to work the way you expect try checking airodump.stdout and airodump.sterr to see what’s going on with your process. Hope that’s enough to get you started.