Datasheet
API in Java
95
/**
* exeecutes already set command.
* @return returns status of the command sent
*/
public String runCommand() {
return writeCommand.runCommand();
}
/**
* Tries to fech data that is repllied to commands sent. It will wait till it can return something.
* @return returns data sent by RouterOS
* @throws java.lang.InterruptedException
*/
public String getData() throws InterruptedException {
String s = (String) queue.take();
return s;
}
/**
* returns command that is set at this moment. And will be exectued if runCommand is exectued.
* @return
*/
public String getCommand() {
return writeCommand.getCommand();
}
/**
* set up method that will log you in
* @param name - username of the user on the router
* @param password - password for the user
* @return
*/
public String login(String name, char[] password) {
this.sendCommand("/login");
String s = "a";
try {
s = this.getData();
} catch (InterruptedException ex) {
Logger.getLogger(ApiConn.class.getName()).log(Level.SEVERE, null, ex);
return "failed read #1";
}
if (!s.contains("!trap") && s.length() > 4) {
String[] tmp = s.trim().split("\n");
if (tmp.length > 1) {
tmp = tmp[1].split("=ret=");
s = "";










