I have some code to execute the unix shell command in background in python
import subprocess
process = subprocess.Popen('find / > tmp.txt &',shell=True)
I need to capture the scenario where i come to know that process has finished successful
completion .
Please explain with sample code
Tazim
Don’t use shell=True. It is bad for your health.
If you really need a file, use
import tempfileinstead of a hard-coded temporary file name. If you don’t need the file, use a pipe (see the subprocess docs as Thomas suggests).Also, don’t write shell scripts in Python. Use the
os.walkfunction instead.