Answers for "run a shell script from python"

3

python run a system command

import os
cmd = "git --version"
returned_value = os.system(cmd)  # returns the exit code in unix
Posted by: Guest on April-01-2020
0

call shell script from python

import subprocess
subprocess.call(["./shell.sh"])

# Make sure that "shell.sh" has "+x" permissions
Posted by: Guest on May-09-2020
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 "run a shell script from python"

Python Answers by Framework

Browse Popular Code Answers by Language