Using specific characters for Shell commands
Hello,
I'm trying to use the Shell FB (which is provided in the PLCnextBase library), to PUT HTPP commands to a server, in order to do this i must be able to add a header and data to the command which requires the character ' (ASCI HEX#27), but this is not possible due to the fact that PLCnext engineer does not allow this. I even tried to convert the string data to a byte array and execute that, but then i get the error that the header requires data to be send, i assume that PLCnext engineer converts the bytes back to an string but then fails to convert HEX#27 to ' and cuts the string of in half. The command i' trying to send is.
curl -X PUT -H 'Content-Type: application/json' -d '{"on": false}' http://192.168.0.219/api//fzegzegreg25486gqglights/1/state
When i do this via putty it works perfectly fine but not in the engineer, is there any way to solve this?
Comments
Hi!
You may try to use escape sequence with \ sign before char symbol you want to transfer to STRING, the final result is:
string_var := 'curl -X PUT -H \'Content-Type: application/json\' -d \'{"on": false}\' http://192.168.0.219/api//fzegzegreg25486gqglights/1/state';
Also, pay attention to the fact that this string is more then 80 chars long, so you have to use UDT String, with extended range aka STRING512 or more.
BR