SAK
SAK

Reputation: 25428

Run an exe from python as a subprocess

I am trying to run the following command from python: C:\Program Files\Electric Cloud\ElectricCommander\bin\ectool --server server.domain.com login "username" "password"

The command is not invoked properly using the below code.

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()

Any idea why it failed?

Upvotes: 0

Views: 351

Answers (1)

mata
mata

Reputation: 69082

You're passing only one paramerter, you need to pass every single parameter as element of a list, eg.:

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()

Upvotes: 1

Related Questions