running multiple bash commands with subprocess

后端 未结 5 1860
盖世英雄少女心
盖世英雄少女心 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:08

    >>> command = "echo a; echo b"
    >>> shlex.split(command);
        ['echo', 'a; echo', 'b']
    

    so, the problem is shlex module do not handle ";"

提交回复
热议问题