<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page import="java.io.BufferedReader, java.io.InputStreamReader, java.io.IOException, java.io.StringWriter, java.io.PrintWriter" %> Ladejobs
<% boolean allSuccess = true; boolean anyRunning = false; try { Runtime runtime = Runtime.getRuntime(); // Execute the system command String[] commands = {"/bin/sh", "-c", "cd ~/alex_skripte/laderoutine && laderoutine.sh"}; Process process = runtime.exec(commands); // Read the output of the command BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); String line; // Start HTML table out.println(""); out.println(""); // Process each line and add to the table while ((line = reader.readLine()) != null) { // Split the line into columns String[] columns = line.split("\\t"); out.println(""); for (String column : columns) { out.println(""); } out.println(""); // Check the status column (assuming it's the fourth column) String status = columns[3].trim(); if (status.equals("Fehler")) { allSuccess = false; } else if (status.equals("läuft gerade...")) { anyRunning = true; } } // End HTML table out.println("
ModulStartEndeStatus
" + column + "
"); // Read the error stream of the command BufferedReader errorReader = new BufferedReader(new InputStreamReader(process.getErrorStream())); while ((line = errorReader.readLine()) != null) { out.println("ERROR: " + line); } // Wait for the command to complete int exitCode = process.waitFor(); // out.println("

Exited with code: " + exitCode + "

"); } catch (IOException | InterruptedException e) { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); out.println("Error: " + sw.toString()); } %>