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.
curl "http://.../alfresco/service/mywebscript"
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.
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;"
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.
Rendering in json ftl worked .
Thank you.