/**
* 执行脚本
* @param command 命令 /scada/reboot.sh
* @param targetDir 执行目录 /scada/command
* @param nodeName 对象名 参数
* @throws Exception 读取命令执行结果异常
*/
public void runScript(String message) {
String command="/scada/reboot.sh";
String nodeName="sec-modbus-master";
try {
String cmd = String.format("%s %s %s", command, nodeName, targetDir);
Process process = Runtime.getRuntime().exec(cmd);
InputStream stdin = process.getInputStream();
InputStreamReader isr = new InputStreamReader(stdin);
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) {
logger.info(line);
}
process.destroy();
} catch (Exception e) {
logger.error("重启程序指令报错"+e.getMessage());
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)