Get returned value on Curl

cancel
Showing results for 
Search instead for 
Did you mean: 
Established Member

Get returned value on Curl

Jump to solution

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"

1 Solution

Accepted Solutions
Customer

Re: Get returned value on Curl

Jump to solution

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. 

View solution in original post

4 Replies
Master

Re: Get returned value on Curl

Jump to solution

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;"

Established Member

Re: Get returned value on Curl

Jump to solution

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.

Customer

Re: Get returned value on Curl

Jump to solution

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. 

View solution in original post

Established Member

Re: Get returned value on Curl

Jump to solution

Rendering in json ftl worked .

Thank you.