Answers for "how to run a bash command in python"

5

How to run bash script in python

import subprocess
print "start"
subprocess.call("sleep.sh")
print "end"
Posted by: Guest on May-20-2020
3

how to execute bash commands in python script

import subprocess
subprocess.call(["sudo", "apt", "update"])
Posted by: Guest on November-17-2019
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

Code answers related to "how to run a bash command in python"

Python Answers by Framework

Browse Popular Code Answers by Language