I have issue using Runtime.getRuntime().exec
String line = "";
String output = "";
Process p = Runtime.getRuntime().exec(new String[]{"dmidecode | grep UUID:"});
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
output += (line + '\n').trim();
}
input.close();
I test this and is not working
String line = "";
String output = "";
Process p = Runtime.getRuntime().exec("dmidecode | grep UUID");
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
output += (line + '\n').trim();
}
input.close();
I get the next error on linux machine:
java.io.IOException: Cannot run program "dmidecode | grep UUID:": error no such file or directory
But I test the command in the console and I get the result!
dmidecode | grep UUID:=> UUID: 564DAF5F-FBF7-5FEE-6BA4-67F0B12D8E0E
How to get the same result using a Java based Process
?