How to use subprocess when multiple arguments contain spaces?

后端 未结 10 2161

I\'m working on a wrapper script that will exercise a vmware executable, allowing for the automation of virtual machine startup/shutdown/register/deregister actions. I\'m t

10条回答
  •  心在旅途
    2021-01-07 18:50

    2 things

    1)

    You probably don't want to use Pipe If the output of the subprogram is greater than 64KB it is likely your process will crash. http://thraxil.org/users/anders/posts/2008/03/13/Subprocess-Hanging-PIPE-is-your-enemy/

    2) Subprocess.Popen has a keyword argument shell, making it as if the shell has been parsing your arguments, setting shell=True should do what you want.

提交回复
热议问题