I am trying to use Java to execute a shell script in Linux(Ubuntu) and trying to redirect the output to another file.
String cmd[] = {"sh", "-c", "my_dir/script.sh > new_dir/out.txt"};
Process pb = Runtime.getRuntime().exec(cmd);
However this us not working properly. I am not able to get the output to be stored in the out.txt file. Could someone suggest a way to do this properly?
new_diralready exist?