Python - Write file in intervals -
i want run command using python script, writes file in 10 seconds interval, read , analyze content.
when execute script, file created content not written.
cmd0 = 'airodump-ng -c '+ channel + ' --bssid ' + bssid + ' --write interval 10 -w psk wlan0mon' cmd0 = cmd0.split() p = popen(cmd0,stdin=pipe, stdout=pipe, stderr=pipe) time.sleep(10)#wait 10 seconds number in range(1, 101): path = 'psk-01.csv' print('read file') time.sleep(10) p.terminate()
but if execute same command directly on terminal, file written correctly.
airodump-ng -c 11 --bssid macx --write-interval 10 -w psk wlan0mon
what can do?
i found solution. put next code:
p = subprocess.popen(cmd0) t =threading.thread(target=myfunction,args=(values,)) t.start() t.join() p.terminate()
instead of next:
p = popen(cmd0,stdin=pipe, stdout=pipe, stderr=pipe) time.sleep(10)#wait 10 seconds number in range(1, 101): path = 'psk-01.csv' print('read file') time.sleep(10) p.terminate()
and works!
Comments
Post a Comment