Community discussions

MikroTik App
 
David1234
Forum Guru
Forum Guru
Topic Author
Posts: 1424
Joined: Sun Sep 18, 2011 7:00 pm

Java API - save only the value ?

Wed Mar 17, 2021 4:14 pm

Hello,
this is my first use time using JAVA api
I just want to save value from my script environment

this is the command I'm using
public static void main(String[] args)  throws Exception
    {
        ApiConnection con = ApiConnection.connect("10.0.0.1"); // connect to router
        con.login("admin","admin"); // log in to router
         List<Map<String, String>> rs = con.execute("/system/script/environment/print where name=ID return value ");
        for (Map<String,String> r : rs) {
              ID = r.toString();
        }
        System.out.println("this is the router id - " + ID);
        con.close(); // disconnect from router
    }
I get this:
this is the router id - tag=2, data={value=Office1}
is there some command in the API that will return only the value ? ot I need to do some manipolation to the answer? (split,cut, etc....)

Thanks,

Who is online

Users browsing this forum: rextended and 28 guests