Commits

Anonymous committed 87aca5e

add suppresssystemout attribute to optionally make sshexec silent PR 52070

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@144737013f79535-47bb-0310-9956-ffa450edef68

  • Participants
  • Parent commits f1f3df2

Comments (0)

Files changed (5)

File CONTRIBUTORS

 Ingenonsya France
 Ingmar Stein
 Irene Rusman
+Isaac Shabtay
 Ivan Ivanov
 J Bleijenbergh
 Jack J. Woehr
 Steve Morin
 Steve Wadsworth
 Steven E. Newton
+Sudheer Chigurupati
 Takashi Okamoto
 TAMURA Kent
 Taoufik Romdhane
  * Add the possibility to register a custom command line argument processor.
    See org.apache.tools.ant.ArgumentProcessor and manual/argumentprocessor.html
 
+ * add the possibility to suppress stdout in the sshexec task.
+   Bugzilla Report 50270.
+
 Changes from Ant 1.8.3 TO Ant 1.8.4
 ===================================
 

File contributors.xml

     <last>Rusman</last>
   </name>
   <name>
+    <first>Isaac</first>
+    <last>Shabtay</last>
+  </name>
+  <name>
     <first>Ivan</first>
     <last>Ivanov</last>
   </name>
     <last>Newton</last>
   </name>
   <name>
+    <first>Sudheer</first>
+    <last>Chigurupati</last>
+  </name>
+  <name>
     <first>Takashi</first>
     <last>Okamoto</last>
   </name>

File manual/Tasks/sshexec.html

      <td valign="top" align="center">No, defaults to an empty string.</td>
   </tr>
   <tr>
+    <td valign="top">suppresssystemout</td>
+    <td valign="top">Whether to suppress system out.
+      <em>since Ant 1.9.0</em></td>
+    <td align="center" valign="top">No, defaults to false</td>
+  </tr>
+  <tr>
     <td valign="top">output</td>
     <td valign="top">Name of a file to which to write the output.</td>
     <td align="center" valign="top">No</td>

File src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java

 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;
         "Timeout period exceeded, connection dropped.";
 
     /**
+     * To supress writing logs to System.out
+     */
+    private boolean suppressSystemOut = false;
+    
+    /**
      * Constructor for SSHExecTask.
      */
     public SSHExec() {
     }
 
     /**
+     * If suppressSystemOut is <code>true</code>, output will not be sent to System.out<br/>
+     * If suppressSystemOut is <code>false</code>, 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.");
         }
     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) {
             }
         }
     }
-}
+
+}