LogicMachine Forum
Set value of object with curl - Printable Version

+- LogicMachine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Set value of object with curl (/showthread.php?tid=985)



Set value of object with curl - baggins - 11.09.2017

Hi,

I would like to set an object value from another machine.
I can do this manually from a web browser using this url:


Code:
http://remoteusr:remotepasswd@192.168.0.40:80/scada-remote?m=json&r=grp&fn=write&alias=15/0/87&value=1


When I use curl on the other machine as follows:


Code:
curl -0 -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST http://remoteusr:remotepasswd@192.168.0.40:80/scada-remote?m=json&fn=write&alias=15/0/87&value=1


the following is returned:

Code:
[1] 6322 [2] 6323 [3] 6324 [4] 6325 [2]   Klaar                   r=grp [3]-  Klaar                   fn=write [emm@bilbo 23]$ HTTP/1.1 200 OK Server: nginx Date: Mon, 11 Sep 2017 09:56:56 GMT Content-Type: text/plain Content-Length: 31 Connection: close Invalid parameter "r" (request)

The object value is not set.

I'm not particularly familiar with curl and there are a million options to it, so can anyone help me out?
Thanks.


RE: Set value of object with curl - baggins - 11.09.2017

I've found the solution by using this command:


Code:
curl -0 -i -H "Accept: application/json" -H "Content-Type: application/json" --data "m=json&r=grp&fn=write&alias=15/&value=0"  http://remoteusr:remotepasswd@192.168.0.40:80/scada-remote



RE: Set value of object with curl - admin - 11.09.2017

Or just escape the whole url with ""


RE: Set value of object with curl - baggins - 11.09.2017

(11.09.2017, 13:32)admin Wrote: Or just escape the whole url with ""

That also works indeed!

Thanks.