Page 1 of 1

Set TEXT of a virtual text device with spaces

Posted: Tuesday 15 March 2016 18:42
by Number8
I'm trying to set the value of the TEXT virtual device using bash and curl, the value having spaces.
I have no problems with the following command in a brower

Code: Select all

http://192.168.21.240:8080/json.htm?type=command&param=udevice&idx=217&nvalue=0&svalue=Please power ON this gear 
However when using this code

Code: Select all

message="Please power on this gear"
messageIDX=217
curl --silent $DOMOTICZSERVER:$DOMOTICZPORT'/json.htm?type=command&param=udevice&idx='$messageIDX'&nvalue=0&svalue='$message
Only the first word is displayed. I tried many things including escaping the single quote. At best only the first word of the message is displayed, or using many other solutions I tried an error is trigerred on the server side.
Any clue?
Thank you

Re: Set TEXT of a virtual text device with spaces

Posted: Tuesday 15 March 2016 18:46
by gizmocuz
try do some url encoding

message="Please%20power%20on%20this%20gear"

Re: Set TEXT of a virtual text device with spaces

Posted: Tuesday 15 March 2016 18:47
by RobertH
Use %20 for space.

Sent from my SM-G925K using Tapatalk

Re: Set TEXT of a virtual text device with spaces

Posted: Tuesday 15 March 2016 19:00
by paulvha
I expect the issue with argument passing to curl. try double quotes : "$message"

Re: Set TEXT of a virtual text device with spaces

Posted: Tuesday 15 March 2016 19:49
by Number8
Thanks guys, it did the trick. I'm using the same idea to display accented characters
fyi double quote was one of my first tries. It does not work.