I'm trying to run a command from java. But command is not executing. Can anyone pointout why?
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;
}
In the log it is printing the command correctly.
command sed -i '/L13876110226750000/d' /usr/share/apache-tomcat-6.0.37/webapps/SMS/info_updated.csv
But it is not executing.
-einstead of or in addition to-i?