We are trying to execute following four commands from within a
Java Program.
But only first three are running i.e. 1, 2 and 3.
Can someone explain why the 4th command is not running and what will be the correct way?
1. Runtime.getRuntime().exec(new
String[] {"/bin/sh","-c", "ls / 2>&1 | tee ls.log"});
2. Runtime.getRuntime().exec(new String[] {"/bin/sh","-c", "top -b 2>&1 | tee top.log"});
3. Runtime.getRuntime().exec(new String[] {"/bin/sh","-c", "ls / 2>&1 | grep auto"});
4. Runtime.getRuntime().exec(new String[] {"/bin/sh","-c", "top -b 2>&1 | grep idle"});
Thanks and sincere regards,
Sangeeta