As mentioned in the title. there maybe indirect output from the code. how can i get that
Runtime rt = Runtime.getRuntime();
String[] cmd1 = new String[]{"/bin/sh", "~/Desktop/test.sh"};
Process proc = rt.exec(commands);
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(proc.getInputStream()));
BufferedReader stdError = new BufferedReader(new
InputStreamReader(proc.getErrorStream()));
// read the output from the command
System.out.println("Here is the standard output of the command:\n");
String s = null;
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
}
// read any errors from the attempted command
System.out.println("Here is the standard error of the command (if any):\n");
while ((s = stdError.readLine()) != null) {
System.out.println(s);
}
i have above code. the tricky part is in this test.sh i have
#/bin/bash
echo hello
bash test1.sh
bash test2.sh
and inside both test1.sh and test2.sh
i only have
echo hello
Obviously i have one hello as output instead of 3 lines of hello so my question is i want all 3 lines of hello
how can i do that.