0
java에서 명령을 실행하려고합니다. 그러나 명령은 실행되지 않습니다. 아무도 왜 지적 할 수 있습니까?java에서 Linux 명령 실행
String path = dest+"/info_updated.csv";
File file = new File(path);
String command = "sed -i '/" + subscriberId + "/d' "+file;
System.out.println("command "+command);
Runtime run = Runtime.getRuntime();
Process p = null;
try {
p = run.exec(command);
InputStream errorStream = p.getErrorStream();
p.waitFor();
} catch (IOException ioe) {
ioe.printStackTrace();
System.out.println("ERROR.RUNNING.CMD");
} catch (Exception e) {
e.printStackTrace();
} finally {
p.destroy();
}
return true;
}
로그에 올바르게 명령을 인쇄하고 있습니다.
command sed -i '/L13876110226750000/d' /usr/share/apache-tomcat-6.0.37/webapps/SMS/info_updated.csv
하지만 실행되지 않습니다.
'-e' 대신 또는 이외에'-i'? – user3159253
"실행하지 않음", 모든 스택 추적을 정의 하시겠습니까? 또한, 이것은 tomcat이 SMS webapp –
No shell => no quoting을 재 전개 할 가능성이 높습니다. –