Reputation: 47
I want to send this command in a python program. How can I do this? I do not need to print any response.
curl -k -X PUT 'http://10.210.12.158:10065/iot/put_bulb/true?id=4'
Upvotes: 1
Views: 107
Reputation: 8946
Using os
:
from os import system
system("curl -k -X PUT 'http://10.210.12.158:10065/iot/put_bulb/true?id=4'")
Using subprocess
:
subprocess.Popen("curl -k -X PUT 'http://10.210.12.158:10065/iot/put_bulb/true?id=4'", shell=True)
Upvotes: 1
Reputation: 1347
You can use the shell module to run such commands neatly:
>>> from shell import shell
>>> curl = shell("curl -k -X PUT 'http://10.210.12.158:10065/iot/put_bulb/true?id=4'")
>>> curl.output()
Alternatively, I'd suggest using the requests module for making such http requests from Python.
Upvotes: 1