diff --git a/WHATSNEW b/WHATSNEW index 7a21ec1ec..2e0651301 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -21,6 +21,11 @@ Other changes: attribute. Bugzilla Report 50513. + * the documented inputstring attribute of sshexec has been + implemented and the actually existing attribute inputproperty + documented. + Bugzilla Report 50576. + Changes from Ant 1.8.1 TO Ant 1.8.2 =================================== diff --git a/docs/manual/Tasks/sshexec.html b/docs/manual/Tasks/sshexec.html index caf0aac3f..d86972dcc 100644 --- a/docs/manual/Tasks/sshexec.html +++ b/docs/manual/Tasks/sshexec.html @@ -145,7 +145,7 @@ and won't work with versions of jsch earlier than input A file from which the executed command's standard input is taken. This attribute is mutually exclusive with the - inputstring attribute.
+ inputstring and inputproperty attributes.
When executing more than one command via commandResource, input will be read for each command. since Ant 1.8.0 @@ -158,14 +158,25 @@ and won't work with versions of jsch earlier than since Ant 1.8.0 No, defaults to false + + inputproperty + Name of a property who's content serves as the + input stream for the executed command. This attribute is + mutually exclusive with the input and inputstring + attributes.
+ When executing more than one command via commandResource, input + will be read for each command. + since Ant 1.8.0 + No + inputstring A string which serves as the input stream for the executed command. This attribute is mutually exclusive with the - input attribute.
+ input and inputproperty attributes.
When executing more than one command via commandResource, input will be read for each command. - since Ant 1.8.0 + since Ant 1.8.3 No 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 7bbc1499d..594228876 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 @@ -61,7 +61,8 @@ public class SSHExec extends SSHBase { private String outputProperty = null; // like private File outputFile = null; // like - private String inputProperty = null; // like + private String inputProperty = null; + private String inputString = null; // like private File inputFile = null; // like private boolean append = false; // like @@ -119,6 +120,8 @@ public class SSHExec extends SSHBase { * If used, the content of the file is piped to the remote command * * @param input The file which provides the input data for the remote command + * + * @since Ant 1.8.0 */ public void setInput(File input) { inputFile = input; @@ -127,12 +130,26 @@ public class SSHExec extends SSHBase { /** * If used, the content of the property is piped to the remote command * - * @param inputProperty The property which contains the input data for the remote command. + * @param inputProperty The property which contains the input data + * for the remote command. + * + * @since Ant 1.8.0 */ public void setInputProperty(String inputProperty) { this.inputProperty = inputProperty; } + /** + * If used, the string is piped to the remote command. + * + * @param inputString the input data for the remote command. + * + * @since Ant 1.8.3 + */ + public void setInputString(String inputString) { + this.inputString = inputString; + } + /** * Determines if the output is appended to the file given in * setOutput. Default is false, that is, overwrite @@ -174,9 +191,13 @@ public class SSHExec extends SSHBase { throw new BuildException("Command or commandResource is required."); } - if (inputFile != null && inputProperty != null) { - throw new BuildException("You can't specify both inputFile and" - + " inputProperty."); + int numberOfInputs = (inputFile != null ? 1 : 0) + + (inputProperty != null ? 1 : 0) + + (inputString != null ? 1 : 0); + if (numberOfInputs > 1) { + throw new BuildException("You can't specify more than one of" + + " inputFile, inputProperty and" + + " inputString."); } if (inputFile != null && !inputFile.exists()) { throw new BuildException("The input file " @@ -254,6 +275,9 @@ public class SSHExec extends SSHBase { istream = new ByteArrayInputStream(inputData.getBytes()) ; } } + if (inputString != null) { + istream = new ByteArrayInputStream(inputString.getBytes()); + } try { final ChannelExec channel;