Skip to content
Advertisement

running multiple bash commands with subprocess

If I run echo a; echo b in bash the result will be that both commands are run. However if I use subprocess then the first command is run, printing out the whole of the rest of the line. The code below echos a; echo b instead of a b, how do I get it to run both commands?

JavaScript

Advertisement

Answer

You have to use shell=True in subprocess and no shlex.split:

JavaScript

returns:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement