There is no need for the
&: the command is launched in a separate process, and runs independently.
If you want to wait until the process terminates, use
process = subprocess.Popen('find / > tmp.txt', shell = True)
exitcode = process.wait()
if exitcode == 0:
# successful completion
# error happened
If your program can do something meaningful in the meantime, you can use
poll() to determine if the process has finished.
Furthermore, instead of writing the output to a temporary file and then reading it from your Python program, you can read from the pipe directly. See the
subprocess documentation for details.