运行curl“http://bas.company.com:9200/dispatcher/_search?q=_id:832238”手动传递,但是通过脚本失败,如下所示,下面的错误,是否有人可以在此处提出错误以及如何克服错误?
import os
from subprocess import check_call,Popen,PIPE
gerrit = '832238'
escmd= ("curl \"http://bas.company.com:9200/dispatcher/_search?q=_id:%s\"" %(gerrit)).split(' ')
espipe = Popen(escmd, stdout=PIPE, stderr=PIPE)
(output, error)= espipe.communicate()
#print output
if espipe.returncode != 0:
print "OUTPUT"
print output
raise IOError, "elastic search command %s failed" % (escmd)
错误: -
IOError: phcommand ['curl', '"http://bas.company.com:9200/dispatcher/_search?q=_id:832238"'] failed
答案 0 :(得分:1)
网址周围的双引号是错误的。当shell解析命令行时允许它们(有时甚至是必要的),但是这里不涉及shell。