running multiple bash commands with subprocess

后端 未结 5 1858
盖世英雄少女心
盖世英雄少女心 2020-11-27 12:22

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

5条回答
  •  北海茫月
    2020-11-27 13:15

    If you're only running the commands in one shot then you can just use subprocess.check_output convenience function:

    def subprocess_cmd(command):
        output = subprocess.check_output(command, shell=True)
        print output
    

提交回复
热议问题