We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
it boggles my mind that I had to post a new answer to such a basic question in order to show how to run the command from the question idiomatically. Your answer is long but I don't see such example. Unrelated: avoid cargo-culting. If check_call() works in your case, use it. I had to fix a code that used run() blindly. Missing check=True caused a bug which would be avoided if check_call were used — "check" is in the name, you can't lose it —it is the correct default: don't ignore errors silently. I didn't read further.
@jfs Thanks for the feedback, I was in fact planning to add a section about Bash vs sh but you beat me to it. I'm trying to spell out the specifics in enough detail to help beginners for whom these pitfalls are not obvious so that does get a bit longwinded. Yours should be quite sufficient otherwise; +1
@Stringers I have not tested, but I don't see why it should. If you connect those pipes to something which does some processing, then of course that processing needs to oe accouted for; but it doesn't happen in the pipe itself. The default is to not capture stdout or stderr at all, i.e. whatever gets printed there is out of Python's visibility and control, just like with os.system().
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
complete the sentence: my question is about...
use tags that describe things or concepts that are essential, not incidental to your question
run()blindly. Missingcheck=Truecaused a bug which would be avoided if check_call were used — "check" is in the name, you can't lose it —it is the correct default: don't ignore errors silently. I didn't read further.shbut you beat me to it. I'm trying to spell out the specifics in enough detail to help beginners for whom these pitfalls are not obvious so that does get a bit longwinded. Yours should be quite sufficient otherwise; +1stderr/stdout = subprocess.PIPEhave a higher performance overhead than the default settings?os.system().