On this page
article
Run Shell Command
Execute external commands safely.
Category: subprocess
Problem
Execute external commands safely.
Solution
result = subprocess.run(["git", "status"], capture_output=True, text=True, check=True)
Notes
- Adapt variable names and paths to your project
- Add error handling for production use
- See related chapters in the Learning Path