python - Using subprocess module with curl command -
i'm getting error: function' object unsubscriptable when using subprocess module curl command.
cmd (subprocess.check_call ['curl -x post -u "opt:gggguywqydfydwfh" ' + url + 'job/%s/%s/promotion/' % (job, num)]). i calling using function.
def cmd(sh): proc = subprocess.popen(sh, shell=true, stderr=subprocess.pipe, stdout=subprocess.pipe). can point out problem?
you forgot parens check_call:
subprocess.check_call(["curl", "-x", "post", "-u", "opt:gggguywqydfydwfh",url + 'job/%s/%s/promotion/' % (job, num)]) you trying subprocess.check_call[...
you passing function, check_call returns exit code trying pass 0 popen call sh going fail.
if want output, forget function , use check_output, need pass list of args:
out = subprocess.check_output(["curl", "-x", "post", "-u", "opt:gggguywqydfydwfh", url + 'job/%s/%s/promotion/' % (job, num)]) either way passing check_call popen not way go
Comments
Post a Comment