Home / Python Tips Generated By ChatGPT / The subprocess Module for Running External Commands in Python Run external commands and capture their output. Source Code import subprocess result = subprocess.run(["echo", "Hello from subprocess"], capture_output=True, text=True) print(result.stdout)