0

我正在尝试从 python 运行以下命令: C:\Program Files\Electric Cloud\ElectricCommander\bin\ectool --server server.domain.com login "username" "password"

使用以下代码未正确调用该命令。

from subprocess import Popen, PIPE
toolLocation = "C:\\Program Files\\Electric Cloud\\ElectricCommander\\bin\\ectool"
parameters = "--server server.domain.com login \"username\" \"password\""
output = Popen([toolLocation, parameters ], stdout=PIPE)
print output.stdout.read()

知道为什么失败吗?

4

1 回答 1

1

您只传递一个参数,您需要将每个参数作为列表的元素传递,例如:

from subprocess import Popen, PIPE
toolLocation = "C:\\Program Files\\Electric Cloud\\ElectricCommander\\bin\\ectool"
parameters = ["--server", "server.domain.com", "login", "username", "password"]
output = Popen([toolLocation] + parameters, stdout=PIPE)
print output.stdout.read()
于 2013-05-02T08:06:26.187 回答