Auf Thema antworten

Ich habe ein Start-Stop-Skript für eine meiner Anwendungen. Nun will ich ein Java-Programm schreiben, das die Datei ausführt. Das könnte so aussehen:


[CODE=java]    @Transactional

    public String executeCommand() {


        boolean isWindows = System.getProperty("os.name").toLowerCase().startsWith("windows");

        if (isWindows) {

            return null;

        }


        try {

            Process process = Runtime.getRuntime().exec("/opt/docker/abc/video/services/user_interface_2/start_stop_user_interface_2.sh");


            StringBuilder output = new StringBuilder();


            BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));


            String line;

            while ((line = reader.readLine()) != null) {

                output.append(line).append("\n");

            }


            int exitVal = process.waitFor();

            if (exitVal == 0) {

                return output.toString();

            }

        } catch (IOException e) {

            e.printStackTrace();

        } catch (InterruptedException e) {

            e.printStackTrace();

        }


        return null;

    }[/CODE]


Nur leider funktioniert das nicht.



Oben