Answers for "how to create shell to run python file"

0

how to run shell command in python

import subprocess

process = subprocess.Popen(['echo', 'hi'],
                           stdout=subprocess.PIPE,
                           stderr=subprocess.PIPE)
out, err = process.communicate()
print(out) # hi
print(err) # None
Posted by: Guest on October-31-2021
1

run a shell script from python

import subprocess

output = subprocess.check_output('pidstat -p ALL'.split(' '), stderr=subprocess.STDOUT, universal_newlines=True)
print(output)
Posted by: Guest on June-12-2021

Code answers related to "how to create shell to run python file"

Python Answers by Framework

Browse Popular Code Answers by Language