When a python script is executed inside a python script, I do not get the complete output

46 Views Asked by At

When a python script is executed inside a python script, I do not get the complete output. In my case:

os.system('python -u capture.py > capture.log &')

where capture.py will capture the packets and feeds this to capture.log.

Capture.py will keep sending packets every 100 sec. I couldn't see the complete output in to the file. Only the initial captures are put to capture.log because capture.py doesn't capture any packets after some time.

However, when I execute the same script via "python -u" in the bash prompt, it works.

1

There are 1 best solutions below

0
stovfl On

You can't start a subprocess with io.system(...).
Read the docs: os.system

You have use module-subprocess