Browse Source

allow System.in to be passed to sshexec'ed process. Patch by rosvit. PR 55393

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1555860 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 11 years ago
parent
commit
6307fed882
3 changed files with 25 additions and 0 deletions
  1. +2
    -0
      WHATSNEW
  2. +7
    -0
      manual/Tasks/sshexec.html
  3. +16
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java

+ 2
- 0
WHATSNEW View File

@@ -78,6 +78,8 @@ Fixed bugs:
Other changes: 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 Changes from Ant 1.9.2 TO Ant 1.9.3
=================================== ===================================


+ 7
- 0
manual/Tasks/sshexec.html View File

@@ -191,6 +191,13 @@ and won't work with versions of jsch earlier than
<em>since Ant 1.8.3</em></td> <em>since Ant 1.8.3</em></td>
<td align="center" valign="top">No, defaults to false</td> <td align="center" valign="top">No, defaults to false</td>
</tr> </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> </table>


<h3>Examples</h3> <h3>Examples</h3>


+ 16
- 0
src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java View File

@@ -36,6 +36,7 @@ import org.apache.tools.ant.types.Resource;
import org.apache.tools.ant.types.resources.FileResource; import org.apache.tools.ant.types.resources.FileResource;
import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.util.KeepAliveOutputStream; import org.apache.tools.ant.util.KeepAliveOutputStream;
import org.apache.tools.ant.util.KeepAliveInputStream;
import org.apache.tools.ant.util.TeeOutputStream; import org.apache.tools.ant.util.TeeOutputStream;


import com.jcraft.jsch.ChannelExec; import com.jcraft.jsch.ChannelExec;
@@ -67,6 +68,7 @@ public class SSHExec extends SSHBase {
private File inputFile = null; // like <exec> private File inputFile = null; // like <exec>
private boolean append = false; // like <exec> private boolean append = false; // like <exec>
private boolean usePty = false; private boolean usePty = false;
private boolean useSystemIn = false;


private Resource commandResource = null; private Resource commandResource = null;


@@ -186,6 +188,16 @@ public class SSHExec extends SSHBase {
usePty = b; usePty = b;
} }


/**
* 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>true</code>, output will not be sent to System.out<br/>
* If suppressSystemOut is <code>false</code>, normal behavior * If suppressSystemOut is <code>false</code>, normal behavior
@@ -302,6 +314,10 @@ public class SSHExec extends SSHBase {
istream = new ByteArrayInputStream(inputString.getBytes()); istream = new ByteArrayInputStream(inputString.getBytes());
} }


if (useSystemIn) {
istream = KeepAliveInputStream.wrapSystemIn();
}

try { try {
final ChannelExec channel; final ChannelExec channel;
session.setTimeout((int) maxwait); session.setTimeout((int) maxwait);


Loading…
Cancel
Save