Hi, I’m trying to play a POST command to a lua script, but I get a “bool(false)” response on my system, any help on what’s wrong?
$ curl -X POST http://localhost:8042/tools/execute-script --data-binary @script.lua
Hello,
You should not use “CURLFile()” as the argument to “CURLOPT_POSTFIELDS”.
Instead, the “CURLOPT_POSTFIELDS” must simply contain a plain string containing your Lua script. For instance:
https://stackoverflow.com/a/871445/881731
Also, make sure that the configuration option “ExecuteLuaEnabled” of Orthanc is set to “true”:
https://book.orthanc-server.com/users/configuration.html
Thanks Sebastian , I’ve changed my code to the following structure: although it’s not clear to me if it’s really pure script injection, or if I have to have a file, my system still doesn’t work.
This has been confirmed: “ExecuteLuaEnabled” of Orthanc is set to “true”
<?php $orthanc = "[http://localhsot:8042/](http://localhsot:8042/)"; $url = $orthanc.'tools/execute-script'; //echo $url; .... $curl = curl_init($url); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $headers = array( "Content-Type: application/x-www-form-urlencoded", ); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); //script lua $data = "function OnStoredInstance(instanceId, tags, metadata) if tags['Modality'] == 'DX' then SendToModality(instanceId, 'gepacs') end if tags['Modality'] == 'MR' then SendToModality(instanceId, 'gepacs') end if tags['Modality'] == 'CT' then SendToModality(instanceId, 'gepacs') end end"; curl_setopt($curl, CURLOPT_POSTFIELDS, $data); //for debug only! curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $resp = curl_exec($curl); curl_close($curl); var_dump($resp); ?>