call script via API and get a result

Hi!

Is it possible to call a script with API and get a result?

I`m currently run a script form JAVA via API(using Legrange library):
List<Map<String, String>> results = con.execute(“/system/script/run number=check”);

and get an empty result:
[tag=3, data={}, tag=3, data={}, tag=3, data={}]

is any way in any API library to get a result of script work in pure String?

Try to save the results of your script into global variables then get there values from script/environment

If you use :put in the script, the combined output of all :put calls is going to be returned.

Earlier versions returned it in a !trap reply with a “message” property, while newer versions use a !done reply with a “ret” property.

Note that either way, you’re getting just a single string that way. It’s up to you to parse it further into multiple values and/or type cast it. Using multiple global variables is a more reliable and version consistent way if you’re trying to get multiple values.