0

I have a python script which should execute curl command. I used os.system. command is:

os.system("curl -d 'protection=$protection&Code=$Code' -X POST https://xyz.somecompany.com/web/services/final.php")

and I get and error:

Code missingCode missingWorker with sessionID:xyz

I gues this is a problem with variable which is defined in python script but it can not be called in curl command? or im wrong?

variables are defined in python script as follows:

Code = item.decode("utf-8")
protection = (int(Code) - int(year)) / 2
a11eksandar
  • 145
  • 2
  • 10

1 Answers1

1

You can do it like this:

cmd = "curl -d 'protection={protection}&Code={code}' -X POST https://xyz.somecompany.com/web/services/final.php"
os.system(cmd.format(protection=protection, code=Code))
var211
  • 596
  • 5
  • 10