I want to incorporate shell commands in my python HPC script and I was wondering which python module is better to use - os or subprocess? os seems fairly easier to use but subprocess is the recommended module.
Subprocess Module
Subprocess is a module that can be used for running shell commands (which allow you to
run Linux commands) within your python script. Subprocess is a newer replacement for the os
module in python and is recommended because it has a more secure approach to running shell
commands than the os module which is susceptible to many vulnerabilities. For example,
subprocess does not inherit the user’s environment variables by default.
os Module
os is a module that can be used to run shell commands in python. It is very simple to use
but has been deprecated because of its security risks that subjects it to many vulnerabilities. For
example, os by default, inherits the user’s environment variables.
source: Research/Using Linux commands in a python script.pdf at main · Server246/Research · GitHub