Author: bodewig
Date: Mon Jan 6 15:29:26 2014
New Revision: 1555860
URL: http://svn.apache.org/r1555860
Log:
allow System.in to be passed to sshexec'ed process. Patch by rosvit. PR 55393
Modified:
ant/core/trunk/WHATSNEW
ant/core/trunk/manual/Tasks/sshexec.html
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java
Modified: ant/core/trunk/WHATSNEW
URL:
http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1555860&r1=1555859&r2=1555860&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Mon Jan 6 15:29:26 2014
@@ -78,6 +78,8 @@ Fixed bugs:
Other changes:
--------------
+ * <sshexec> can optionally pass System.in to the remote process
+ Bugzilla Report 55393
Changes from Ant 1.9.2 TO Ant 1.9.3
===================================
Modified: ant/core/trunk/manual/Tasks/sshexec.html
URL:
http://svn.apache.org/viewvc/ant/core/trunk/manual/Tasks/sshexec.html?rev=1555860&r1=1555859&r2=1555860&view=diff
==============================================================================
--- ant/core/trunk/manual/Tasks/sshexec.html (original)
+++ ant/core/trunk/manual/Tasks/sshexec.html Mon Jan 6 15:29:26 2014
@@ -191,6 +191,13 @@ and won't work with versions of jsch ear
<em>since Ant 1.8.3</em></td>
<td align="center" valign="top">No, defaults to false</td>
</tr>
+ <tr>
+ <td valign="top">useSystemIn</td>
+ <td valign="top">Whether to pass the current standard input to the
+ remote process.
+ <em>since Ant 1.9.4</em></td>
+ <td align="center" valign="top">No, defaults to false</td>
+ </tr>
</table>
<h3>Examples</h3>
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java?rev=1555860&r1=1555859&r2=1555860&view=diff
==============================================================================
---
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java
(original)
+++
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java
Mon Jan 6 15:29:26 2014
@@ -36,6 +36,7 @@ import org.apache.tools.ant.types.Resour
import org.apache.tools.ant.types.resources.FileResource;
import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.util.KeepAliveOutputStream;
+import org.apache.tools.ant.util.KeepAliveInputStream;
import org.apache.tools.ant.util.TeeOutputStream;
import com.jcraft.jsch.ChannelExec;
@@ -67,6 +68,7 @@ public class SSHExec extends SSHBase {
private File inputFile = null; // like <exec>
private boolean append = false; // like <exec>
private boolean usePty = false;
+ private boolean useSystemIn = false;
private Resource commandResource = null;
@@ -187,6 +189,16 @@ public class SSHExec extends SSHBase {
}
/**
+ * If set, input will be taken from System.in
+ *
+ * @param useSystemIn True to use System.in as InputStream, false otherwise
+ * @since Apache Ant 1.9.4
+ */
+ public void setUseSystemIn(boolean useSystemIn) {
+ this.useSystemIn = useSystemIn;
+ }
+
+ /**
* 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
@@ -302,6 +314,10 @@ public class SSHExec extends SSHBase {
istream = new ByteArrayInputStream(inputString.getBytes());
}
+ if (useSystemIn) {
+ istream = KeepAliveInputStream.wrapSystemIn();
+ }
+
try {
final ChannelExec channel;
session.setTimeout((int) maxwait);