<%
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("Modul | Start | Ende | Status |
");
// 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("" + column + " | ");
}
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("
");
// 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());
}
%>