javalinuxjava-runtime-compiler

Java Runtime -ERR 'fsctl Command not found


I run a command using java Runtime.That command work fine when i executed normally on terminal/command promp but unable to execute through Java.Runtime :-

        Runtime.getRuntime().exec("fs_cli -H x.x.x.x -x 'fsctl loglevel'");

It give output "-ERR 'fsctl Command not found!"


Solution

  • resolve the error:-

    ProcessBuilder builder = new ProcessBuilder();
    System.out.println(new BufferedReader(new InputStreamReader(builder.command("sh", "-c", "fs_cli -H 10.168.3.135 -x 'fsctl loglevel'").start().getInputStream())).lines().parallel().collect(Collectors.joining("\n")));