I am trying to issue a curl command from python, from command line it works fine :
curl -k --data-binary @GetRequestData.xml -u archala:H@ror1987 https://wsgwtestmg.mass.gov:5550/service/mgmt/current > Response\generated_Resp.xml
but when I called it from python :
from sys import argv
import subprocess
# run python cache2.py hosts.txt Test
with open(argv[1]) as f:
addresses = {i.split(" : ")[0] : i.split(" : ")[1] for i in f}
print(addresses[argv[2]])
command = "curl -k --data-binary @GetRequestData.xml -u archala:H@ror1987 https://" +addresses[argv[2]].strip()+ ":5550/service/mgmt/current > Response\generated_Resp.xml"
print(command)
p = subprocess.Popen(command, stdout=subprocess.PIPE).communicate()[0]
I got : Could not resolve host: >
with the help of swstephe , added shell=True, it worked.
someone mentioned using Requests is a better way, I will appreciated if someone gave me the same using Requests. Thanks.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.