๋ฐ์ํ
command ์ฐฝ์์๋ง ์คํํ๋ ๋ฐฐ์น ํน์ ์์คํฌ๋ฆฝํธ ํ์ผ์ ์๋ฐ์์ ์คํํด์ผํ ์ผ์ด ์๊ฒจ ์๋์ ๊ฐ์ด ์์ฑํ์๋ค.
result๊ฐ์ด 0์ด๋ฉด ์คํ ์ฑ๊ณตํ ๊ฒ!
public boolean runXXXX(String xxxx) {
boolean result = false;
String filePath = "ํ์ผ path";
super.logger.debug("file path : " + filePath);
File file = new File(filePath);
try {
if(file.exists()){
CommandLine cmdLine = CommandLine.parse(filePath+" "+req_id);
DefaultExecutor executor = new DefaultExecutor();
try {
int batch_result = executor.execute(cmdLine);
if(batch_result == 0){
result = true;
}else{
result = false;
super.logger.error("The batch program failed to run.");
return result;
}
} catch (ExecuteException e) {
super.logger.error(PrintStackTraceUtils.getErrStrFromException(e));
result = false;
return result;
} catch (IOException e) {
super.logger.error(PrintStackTraceUtils.getErrStrFromException(e));
result = false;
return result;
}
}else{
super.logger.error("File not found : " + filePath);
result = false;
return result;
}
} catch (Exception e) {
super.logger.error(e.getMessage());
result = false;
}
return result;
}
728x90
๋ฐ์ํ
๋๊ธ