I am trying to run a shell command - cat input.txt | shellscript.sh
as you can see the shell script requires input so i made an input txt.
This commands runs perfectly well in terminal. But I am not sure how it works in java.
so to make this work, I made another script called command.sh which just has this shell commmand - cat input.txt | shellscript.sh
and i placed them all in the same directories. When i run it, there are no errors but the commands inside the script does not seem to run.
public class testing {
public static void main(String[] args) throws IOException,InterruptedException {
Process p = new ProcessBuilder("/bin/sh", "/Random Files/command.sh").start();
}
}
Any idea how to get it working? or can I just call the command - cat input.txt | shellscript.sh somehow to make it work? Also can you please tell me how to get the output?