Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
作为子进程从python运行exe_Python_Subprocess - Fatal编程技术网

作为子进程从python运行exe

作为子进程从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

我正在尝试从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"
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'
,它将执行该命令