I am trying to execute the command below using Popen(shlex.split(cmd)... and Popen(cmd.split(' ')...but running into errors below, how else can I run this command or how to debug this error?
def function_create_cmds(cmd): print cmd #proc = Popen(shlex.split(cmd), shell=True, stdout=PIPE, stderr=PIPE) proc = Popen(cmd.split(' '), stdout=PIPE, stderr=PIPE) (output, error) = proc.communicate() return output,error cmd = "/usr/local/bin/xbs submitproject -notesfile /Users/usernamea/autosubmissionlogs/07162018_133945/milestone/project-375/project-375.plist -version project-1.0.7 /Users/usernamea/wifiroots/project Release" (output,error) = function_create_cmds(cmd) print output print error Error:
Popen(cmd.split(' '), INFO: submitproject was unable to locate a submission directory named Popen(shlex.split(cmd) xbs requires a command
cmdas string seems already not good, or else split would have worked. materialize your arguments in a list, don't pass a string.shlex.split(cmd)withoutshell=Truewhich still doesnt workshlex.split(cmd)-- it's significantly worse than an explicit list, as the explicit list will work with filenames with spaces and the like, whereasshlex.split()requires them to be escaped).cmd.split(' '), thenprint(repr(cmd.split(' ')))in your code, and edit the output into your question. If you're usingshlex.split(cmd), likewise, edit the output ofprint(repr(shlex.split(cmd)))into the question.