代码如下:
Runtime currentRT = Runtime.getRuntime();
Process proc = null;
String command = “/opt/Lnsyhn/CCDD/CDAB/compre.sh”;
String command = “gzip -d /opt/Lnsyhn/CCDD/CDAB/ALARM*.gz”;
String[] command = new String[]{“gzip -d /opt/Lnsyhn/CCDD/CDAB/ALARM*.gz”, “ls”, “cd /”};
proc = currentRT.exec(command);
// 执行
int result = proc.waitFor();
proc.waitFor() 返回值含义网上有。