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

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -