Get output of shell command using RootTools

135 Views Asked by At

I would like to get the output of a shell command, "ls -l" for example using RootTools and pass it to a variable or array so that i can manipulate it.

This is the code that i use but does not work.

final StringBuilder s = new StringBuilder();
final Command command = new Command(0, "ls -l") {      
    public void commandOutput(int id, String line) {
                    s.append(line);
                    super.commandOutput(id, line);
                    System.out.println(s.toString());
        }                   
    };

    try {
         RootTools.getShell(true).add(command);
    } catch (IOException | RootDeniedException | TimeoutException e) {
         e.printStackTrace();
    }
0

There are 0 best solutions below