I am trying to create a python program that can periodically poll the output from airodump-ng, a wifi sniffing tool. I am doing this on a RPI running Raspbian and Python 3.4 I've looked up how to do this on several website but whenever I try this I get a sort of deadlock and the program stalls.
I am using this code:
import subprocess
airodump = subprocess.Popen(['sudo','airodump-ng','mon0'])
out,err = airodump.communicate(timeout=10)
So the weird thing is that when I type these commands one by one into IDLE running on the RPI, everything works but after 10 seconds I get a timeout error. When not using the timeout argument, the program simply stalls. Using the extra argument 'stdout=subprocess.PIPE' also doesn't work. But when I go to terminal and start up python using the command 'python3' and then typing in the first and second line, the whole screen is then filled with the output from airodump-ng and I cannot type anything anymore!
So how can I solve this? I just want to get the most recent output from airodump-ng and the output of airodum-ng can simply be updated in the background, in another thread. I just want the most recent output.