作为子进程从python运行exe
我正在尝试从python运行以下命令:作为子进程从python运行exe,python,subprocess,Python,Subprocess,我正在尝试从python运行以下命令: C:\Program Files\Electric Cloud\ElectricCommander\bin\ectool--server.domain.com登录“用户名”“密码” 未使用以下代码正确调用该命令 from subprocess import Popen, PIPE toolLocation = "C:\\Program Files\\Electric Cloud\\ElectricCommander\\bin\\ectool" parame
C:\Program Files\Electric Cloud\ElectricCommander\bin\ectool--server.domain.com登录“用户名”“密码”
未使用以下代码正确调用该命令
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()
知道它失败的原因吗?您只传递了一个参数,您需要将每个参数作为列表的元素传递,例如:
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()
如果我放置
参数='--version'
,它将执行该命令