Java実行Shellスクリプト
419 ワード
String[] cmd = new String[]{"sh", "-c", shell };
System.out.println(cmd.toString());
Process process = null;
try {
process = Runtime.getRuntime().exec(cmd);
// ,
process.waitFor();
} catch (Exception error) {
error.printStackTrace();
LOG.error(error.getMessage());
}finally{
if(process!=null){
process.destroy();
}
}