Takashi
Okamoto
diff --git a/manual/Tasks/sshexec.html b/manual/Tasks/sshexec.html
index 38e5b35e3..0c130e812 100644
--- a/manual/Tasks/sshexec.html
+++ b/manual/Tasks/sshexec.html
@@ -115,6 +115,12 @@ and won't work with versions of jsch earlier than
Passphrase for your private key. |
No, defaults to an empty string. |
+
+ suppresssystemout |
+ Whether to suppress system out.
+ since Ant 1.9.0 |
+ No, defaults to false |
+
output |
Name of a file to which to write the output. |
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java
index 2258d515e..113565101 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java
@@ -27,6 +27,7 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.io.OutputStream;
import java.io.StringReader;
import org.apache.tools.ant.BuildException;
@@ -72,6 +73,11 @@ public class SSHExec extends SSHBase {
private static final String TIMEOUT_MESSAGE =
"Timeout period exceeded, connection dropped.";
+ /**
+ * To supress writing logs to System.out
+ */
+ private boolean suppressSystemOut = false;
+
/**
* Constructor for SSHExecTask.
*/
@@ -180,12 +186,22 @@ public class SSHExec extends SSHBase {
usePty = b;
}
+ /**
+ * If suppressSystemOut is true
, output will not be sent to System.out
+ * If suppressSystemOut is false
, normal behavior
+ * @since Ant 1.9.0
+ */
+ public void setSuppressSystemOut(boolean suppressSystemOut)
+ {
+ this.suppressSystemOut = suppressSystemOut;
+ }
/**
* Execute the command on the remote host.
*
* @exception BuildException Most likely a network error or bad parameter.
*/
public void execute() throws BuildException {
+
if (getHost() == null) {
throw new BuildException("Host is required.");
}
@@ -262,9 +278,7 @@ public class SSHExec extends SSHBase {
private void executeCommand(Session session, String cmd, StringBuffer sb)
throws BuildException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
- TeeOutputStream tee =
- new TeeOutputStream(out,
- KeepAliveOutputStream.wrapSystemOut());
+ OutputStream tee = suppressSystemOut ? out : new TeeOutputStream(out, KeepAliveOutputStream.wrapSystemOut());
InputStream istream = null ;
if (inputFile != null) {
@@ -407,4 +421,5 @@ public class SSHExec extends SSHBase {
}
}
}
-}
\ No newline at end of file
+
+}