diff --git a/WHATSNEW b/WHATSNEW index 82d1cde4e..4fa1383e7 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -78,6 +78,8 @@ Fixed bugs: Other changes: -------------- + * can optionally pass System.in to the remote process + Bugzilla Report 55393 Changes from Ant 1.9.2 TO Ant 1.9.3 =================================== diff --git a/manual/Tasks/sshexec.html b/manual/Tasks/sshexec.html index 0c130e812..75f0faf19 100644 --- a/manual/Tasks/sshexec.html +++ b/manual/Tasks/sshexec.html @@ -191,6 +191,13 @@ and won't work with versions of jsch earlier than since Ant 1.8.3 No, defaults to false + + useSystemIn + Whether to pass the current standard input to the + remote process. + since Ant 1.9.4 + No, defaults to false +

Examples

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 113565101..d7f92a382 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 @@ -36,6 +36,7 @@ import org.apache.tools.ant.types.Resource; 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 private boolean append = false; // like private boolean usePty = false; + private boolean useSystemIn = false; private Resource commandResource = null; @@ -186,6 +188,16 @@ public class SSHExec extends SSHBase { 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 true, output will not be sent to System.out
* If suppressSystemOut is false, normal behavior @@ -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);