I am using Popen to run a command but I don't know how I can write a callback that gets called once the command is finished. Any idea?
Thanks. Bin
You can call communicate():
p = subprocess.Popen('find . -name "*.txt"', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
You can also call wait(), but this might cause problems if the child process fills its output buffer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With