com.arch.util.SoftwareUtils Maven / Gradle / Ivy
package com.arch.util;
import java.io.IOException;
public final class SoftwareUtils {
private SoftwareUtils() {
}
public static boolean runningLinux(String programa) {
try {
StringBuilder sb = new StringBuilder();
LineCommandUtils.executaCommando("ps -ef | grep " + programa + " | wc -l ", sb);
return !sb.toString().equals("2");
} catch (InterruptedException | IOException e) {
LogUtils.generate(e);
}
return false;
}
public static boolean runningWindows(String programa) {
try {
StringBuilder sb = new StringBuilder();
int retorno = LineCommandUtils.executaCommando("tasklist /FI \"IMAGENAME eq " + programa.toLowerCase() + "\"", sb);
LogUtils.generate("TAMANHO do sb = " + sb.length() + " e o retorno = " + retorno);
if (sb.length() == 0) {
return false;
} else if (!sb.toString().contains(programa)) {
return false;
}
return (sb.length() > 0);
} catch (Exception ex) {
return false;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy