'Running a command within a Python os.system tag
I am trying to control my lights via a simple discord bot but am running into an issue. I need to run this command and am using discord.py to do it:
if message.content.startswith('$Light-Blue'):
await os.system('coap-client -m put -u "demo" -k "X2CYInVgcFN7i26k" -e '{ "3311": [{ "5706": "4a418a" }] }' "coaps://192.168.110.241:5684/15001/65537"')
await message.channel.send('Turned changed color 1 Light')
The issue I am having is that Python tries to interpret the commands as Python code because of the tags used. So I get a syntax error. How do fix the code so that Python stops treating the commands as code?
This is the error I am getting:
File "bot.py", line 25
await os.system('coap-client -m put -u "demo" -k "X2CYInVgcFN7i26k" -e '{ "3311": [{ "5706": "4a418a" }] }' "coaps://192.168.110.241:5684/15001/65537"')
^
SyntaxError: invalid syntax
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
