NCO
(E. Gerland)
May 10, 2022, 4:38pm
1
I am on OH3 and can succefully set my alarmsystem with curl from a commanline with:
curl -v 'admin:pwd@192.168.68.31/action/panelCondPost?area=1&mode=1' -H 'X-Token:MySecretToken'
I know, that space separated commands need to be like:
"curl", "-v", "admin", ...
And I tried many different versions without success:
val execToken = xToken + "'"
answer = executeCommandLine(Duration.ofSeconds(6), "curl", "-v", "'admin:pwd@192.168.68.31/action/panelCondPost?area=1&mode=0'", "-H", "'X-Token:" , execToken)
or
val execCMD = "curl -v 'admin:pwd@192.168.68.31/action/panelCondPost?area=1&mode=0' -H 'X-Token:" + execToken
answer = executeCommandLine(Duration.ofSeconds(6), execCMD)
with or without @@ instead of the space.
none of these worked.
because I need to retrieve the token beforehand I cannot “hardcode” it.
Any help is greatly appreciated.
rlkoshak
(Rich Koshak)
May 10, 2022, 4:46pm
2
It’s not just a blanket rule where every space separates an argument. In this case the “-v” and “admin” are part of the same argument passed to curl. So treat those as one argument.
"curl", "-v admin", ...
At the end, there isn’t even a space between ‘x-Token:’ and execToken
. That one at a minimum should be just one value passed to executeCommandLine.
"-H 'X-Token:"+execToken+"'"
NCO
(E. Gerland)
May 10, 2022, 5:09pm
3
rlkoshak:
"curl", "-v admin", ...
hmmm…
But for retrieving the token this works:
val response = executeCommandLine(Duration.ofSeconds(6), "curl", "-s", "admin:pwd@192.168.68.31/action/tokenGet")
so you mean it should look like this then:
answer = executeCommandLine(Duration.ofSeconds(6), "curl", "-v 'admin:pwd@192.168.68.31/action/panelCondPost?area=1&mode=2' -H 'X-Token:"+execToken+"'")
This returns:
curl: option -v admin:pwd@192.168.68.31/action/panelCondPost?area=1&mode=2 -H X-Token:MYTOKEN: is unknown
GOT IT!
THank you very much @rlkoshak !
This works:
"curl", "-v", "admin:pwd@192.168.68.31/action/panelCondPost?area=1&mode=2", "-H", "X-Token:"+xToken)