-1

I am trying to run the command "tool --server=commander.company.com runProcedure Android_Main --procedureName priority_kw --actualParameter priority_changes="769373 769374" gerrit_server=review-android.company.com" using below code, trying to put the value in variable "var" but not able to ?can anyone suggest what should be changed in below code to run the above command?

var = "769373 769374"

#tool --server=commander.company.com runProcedure Android_Main --procedureName priority_kw --actualParameter priority_changes="769373 769374" gerrit_server=review-android.company.com
cmd = "tool --server=commander.company.com runProcedure Android_Main --procedureName priority_kw --actualParameter priority_changes=\"{0}\" gerrit_server=review-android.company.com".format(var)

Pipe = Popen(cmd.split(), stdout=PIPE, stderr=PIPE)
(output, error) = Pipe.communicate()
print output
print error
Bachmann
  • 748
  • 6
  • 12
user3654069
  • 345
  • 2
  • 6
  • 14

1 Answers1

1

When you split your command, you're separating the two parts of "769373 769374". Just write out the list yourself instead of using split:

cmd = ['tool', '--server=commander.company.com', 'runProcedure', 'Android_Main',
       '--procedureName', 'priority_kw', '--actualParameter',
       'priority_changes="769373 769374"',
       'gerrit_server=review-android.company.com']

Pipe = Popen(cmd, stdout=PIPE, stderr=PIPE)

If you still want to split automatically, you can look at this question for splitting the string correctly using regular expressions.

Community
  • 1
  • 1
Lily Chung
  • 2,919
  • 1
  • 25
  • 42