SED command is not executing when I'm trying it to execute with Java, while it is getting executed successfully manually. No response & no error is seen in output.
My SED Command: Manually:
sed -i 's/abc/xyz/' /home/tmp.txt
In java file:
String[] cmdtest = {"sed ", "-i","'s/abc/xyz/'"," /home/tmp.txt"};
Process:
StringBuffer output = new StringBuffer();
Process p = null;
try {
p = Runtime.getRuntime().exec(cmdtest);
p.waitFor();
BufferedReader reader =
new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = "";
while ((line = reader.readLine())!= null) {
output.append(line + "\n");
}
} catch (Exception e) {
e.printStackTrace();
}