Hi I've seen the following code mentioned in several examples:
channel.setOutputStream(System.out); First of all, I think the various examples should have the second parameter "dontclose" set to true, otherwise JSch will close System.out/err and the Java program will terminate! But more importantly, I cannot get it to work. Basically I'm doing this: ChannelExec channel = (ChannelExec) session.openChannel("exec"); channel.setCommand("./test.sh"); channel.setInputStream(null); channel.setOutputStream(System.out, true); channel.setErrStream(System.err, true); channel.connect(); while (!channel.isClosed()) { Thread.sleep(100); } channel.disconnect(); The "test.sh" remote script prints something to both streams and sleeps for a few seconds: #!/bin/sh echo Hello echo Hello err >&2 sleep 10 I can confirm that the loop waits for the remote script to end (if I set the remote script to sleep for 10 sec, the loop waits for 10 sec, etc.) but I don't get anything printed on the local terminal, neither stdout nor stderr. I'm using Java 1.7.0_101 on Linux 64bit and JSch 0.1.53, but I have also tried previous JSch versions, with the same results. What am I doing wrong? -Tobia PS: I have posted the same question here with a longer example: http://stackoverflow.com/questions/37167331/jsch-output-to-terminal ------------------------------------------------------------------------------ Mobile security can be enabling, not merely restricting. Employees who bring their own devices (BYOD) to work are irked by the imposition of MDM restrictions. Mobile Device Manager Plus allows you to control only the apps on BYO-devices by containerizing them, leaving personal data untouched! https://ad.doubleclick.net/ddm/clk/304595813;131938128;j _______________________________________________ JSch-users mailing list JSch-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jsch-users