I'm executing a linux command in java using processBuilder but it adds [?1034h
as the last line.
It is printing all lines but after my expected last line, it adds another line with those characters.
My code:
ProcessBuilder processBuilder = new ProcessBuilder();
// -- Linux --
// Run a shell command
processBuilder.command("bash", "-c", "sudo /usr/sbin/ilorest load -f "+biossource);
try {
Process process = processBuilder.start();
output = new StringBuilder();
BufferedReader reader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
output.append(line);
}
BufferedReader stdError = new BufferedReader(new
InputStreamReader(process.getErrorStream()));
System.out.println("Here is the standard error of the command (if any):\n");
while ((line = stdError.readLine()) != null) {
output.append(line);
System.out.println(line);
}
int exitVal = process.waitFor();
if (exitVal == 0) {
System.out.println("Success!");
System.out.println(output);
System.exit(0);
} else {
//abnormal...
}
I also wrote the output to file and even there it is showing the same.