在程序所在的服务器上面执行命令,并打印命令执行之后的结果
public String excuteCommand(Process proc, InputStream stderr, InputStreamReader isr, BufferedReader br, String command, String result, String status) {
Runtime rt = Runtime.getRuntime();
Map<String, String> onuMap = new HashMap();
String line = "";
// 执行命令, 最后一个参数,可以使用new File("path")指定运行的命令的位置
try {
logger.info("######## status command =" + command);
proc = rt.exec(command, null, null);
stderr = proc.getInputStream();
isr = new InputStreamReader(stderr, "UTF-8");
br = new BufferedReader(isr);
while ((line = br.readLine()) != null) { // 打印出命令执行的结果
logger.info("##########返回报文结果=" + line);
}
} catch (IOException e) {
logger.error("获取ONU误码值失败", e);
}
return line;
}