diff --git a/src/fr/devinsy/util/cmdexec/demo/CmdExecDemo.java b/src/fr/devinsy/util/cmdexec/demo/CmdExecDemo.java index 814c4fd..0ee6b70 100644 --- a/src/fr/devinsy/util/cmdexec/demo/CmdExecDemo.java +++ b/src/fr/devinsy/util/cmdexec/demo/CmdExecDemo.java @@ -48,7 +48,7 @@ public class CmdExecDemo { // BasicConfigurator.configure(); - org.apache.log4j.Logger.getRootLogger().setLevel(Level.ERROR); + org.apache.log4j.Logger.getRootLogger().setLevel(Level.INFO); Logger logger = LoggerFactory.getLogger(CmdExecDemo.class); // @@ -63,7 +63,9 @@ public class CmdExecDemo System.out.println("Launch…"); - String result = CmdExecUtils.run("/bin/bash", "-c", "echo '10\n5\n7\n1' > " + tmpFile.getAbsolutePath()); + // String result = CmdExecUtils.run("/bin/bash", "-c", + // "echo '10\n5\n7\n1' > " + tmpFile.getAbsolutePath()); + String result = CmdExecUtils.run("/bin/bash -c \"echo '10\n5\n7\n1' > " + tmpFile.getAbsolutePath() + " \""); System.out.println("result=[" + result + "]"); } @@ -89,8 +91,22 @@ public class CmdExecDemo System.out.println("Launch…"); - // String command = "/bin/sort -r /etc/passwd"; - String[] command = { "/usr/bin/sort", "-n", "-r", tmpFile.getAbsolutePath() }; + String[] command = { "/usr/bin/sort", "-n", tmpFile.getAbsolutePath() }; + + CmdExec cmdexec = new CmdExec(command, StreamGobbler.StreamWay.BUFFER, StreamGobbler.StreamWay.BUFFER); + System.out.println("command=[" + cmdexec.toString() + "]"); + System.out.println("exitVal=[" + cmdexec.getExitValue() + "]"); + System.out.println("out=[" + cmdexec.getOutStream() + "]"); + System.out.println("err=[" + cmdexec.getErrStream() + "]"); + } + + // #3 + { + System.out.println("========== DEMO #3;"); + + System.out.println("Launch…"); + + String command = "/usr/bin/sort -n -r " + tmpFile.getAbsolutePath(); CmdExec cmdexec = new CmdExec(command, StreamGobbler.StreamWay.BUFFER, StreamGobbler.StreamWay.BUFFER); System.out.println("command=[" + cmdexec.toString() + "]");