import subprocess | |
pl = subprocess.Popen(['ps', '-U', '0'], stdout=subprocess.PIPE).communicate()[0] | |
print(pl.decode('utf-8')) |
# Method 1 | |
# =============== | |
import subprocess | |
subprocess.call(['./test.sh']) # Thanks @Jim Dennis for suggesting the [] | |
# Method 2 | |
# =============== | |
import os | |
os.system('command') | |
os.system('ls -l') | |
# Method 23 | |
# =============== | |
import subprocess | |
import shlex | |
subprocess.call(shlex.split('./test.sh param1 param2')) | |
# Refer - https://janakiev.com/blog/python-shell-commands/ |
I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND