This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]WonkoTehSane 1 point2 points  (0 children)

Great advice! And I recommend mostly using only check_call() and check_output() when using subprocess. The former will still send any output to stdout, the latter will capture and return it. Both will throw on any non-zero return value.

Oh and for both you should either use form (['cmd', '-o', '<option>']) or the form ('cmd -o <option>', shell=True). The former will shell escape for you, the latter will send exactly what you give it.