How to run multiple commands in Python
This example will show you, how to run a multiple bash commands with subprocess in python.
We need to use shell=True
in subprocess:
def subprocess_cmd(command):
process = subprocess.Popen(command,stdout=subprocess.PIPE, shell=True)
proc_stdout = process.communicate()[0].strip()
print proc_stdout
subprocess_cmd('echo c; echo d')
Output:
c
d