08-02-2017 08:37 PM
I have a main function in my webscript:
mywebscript.js
function main()
{
....
....
return arr;
}
main();
How do I get arr when I call this script using curl command.
08-03-2017 12:51 PM
Hi:
Your freemaker template may render in json format, and then you can parse your curl result via jq or jshon commands instead of greping this way.
Regards.
--C.
08-03-2017 07:52 AM
You must write a response template using FreeMarker template to render the HTTP response. You will not automatically get "arr" as a response. Also, for the template to be able to render elements of "arr" you must put it into the "model" variable, e.g. "model.arr = arr;"
08-03-2017 12:43 PM
Yeah I can write "model.arr = arr" in my script and fetch its value in FreeMarker template using ${arr}. but arr is an associative array and I need to loop through that and feed the values into an sql table which is where I am calling the curl command in a ruby based script.
I can fetch the value of a <p></p> tag of FreeMarker template file using :
curl "http://.../alfresco/service/mywebscript" | grep \'(?<=<p>).*?(?=</p>)\' but I cannot grep on a table and get the value of multiple <td></td>s.
And that is why I need arr to fetch where I am calling curl.
08-03-2017 12:51 PM
Hi:
Your freemaker template may render in json format, and then you can parse your curl result via jq or jshon commands instead of greping this way.
Regards.
--C.
08-03-2017 05:44 PM
Rendering in json ftl worked .
Thank you.
Explore our Alfresco products with the links below. Use labels to filter content by product module.