Browse Source

Actually implement inputstring and document inputproperty. PR 50576

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1063224 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 14 years ago
parent
commit
8a8bbe2fb9
3 changed files with 48 additions and 8 deletions
  1. +5
    -0
      WHATSNEW
  2. +14
    -3
      docs/manual/Tasks/sshexec.html
  3. +29
    -5
      src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java

+ 5
- 0
WHATSNEW View File

@@ -21,6 +21,11 @@ Other changes:
attribute. attribute.
Bugzilla Report 50513. 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 Changes from Ant 1.8.1 TO Ant 1.8.2
=================================== ===================================




+ 14
- 3
docs/manual/Tasks/sshexec.html View File

@@ -145,7 +145,7 @@ and won't work with versions of jsch earlier than
<td valign="top">input</td> <td valign="top">input</td>
<td valign="top">A file from which the executed command's standard <td valign="top">A file from which the executed command's standard
input is taken. This attribute is mutually exclusive with the input is taken. This attribute is mutually exclusive with the
inputstring attribute.<br/>
inputstring and inputproperty attributes.<br/>
When executing more than one command via commandResource, input When executing more than one command via commandResource, input
will be read for each command. will be read for each command.
<em>since Ant 1.8.0</em></td> <em>since Ant 1.8.0</em></td>
@@ -158,14 +158,25 @@ and won't work with versions of jsch earlier than
<em>since Ant 1.8.0</em></td> <em>since Ant 1.8.0</em></td>
<td align="center">No, defaults to false</td> <td align="center">No, defaults to false</td>
</tr> </tr>
<tr>
<td valign="top">inputproperty</td>
<td valign="top">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.<br/>
When executing more than one command via commandResource, input
will be read for each command.
<em>since Ant 1.8.0</em></td>
<td align="center" valign="top">No</td>
</tr>
<tr> <tr>
<td valign="top">inputstring</td> <td valign="top">inputstring</td>
<td valign="top">A string which serves as the input stream for the <td valign="top">A string which serves as the input stream for the
executed command. This attribute is mutually exclusive with the executed command. This attribute is mutually exclusive with the
input attribute.<br/>
input and inputproperty attributes.<br/>
When executing more than one command via commandResource, input When executing more than one command via commandResource, input
will be read for each command. will be read for each command.
<em>since Ant 1.8.0</em></td>
<em>since Ant 1.8.3</em></td>
<td align="center" valign="top">No</td> <td align="center" valign="top">No</td>
</tr> </tr>
</table> </table>


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

@@ -61,7 +61,8 @@ public class SSHExec extends SSHBase {


private String outputProperty = null; // like <exec> private String outputProperty = null; // like <exec>
private File outputFile = null; // like <exec> private File outputFile = null; // like <exec>
private String inputProperty = null; // like <exec>
private String inputProperty = null;
private String inputString = null; // like <exec>
private File inputFile = null; // like <exec> private File inputFile = null; // like <exec>
private boolean append = false; // like <exec> private boolean append = false; // like <exec>


@@ -119,6 +120,8 @@ public class SSHExec extends SSHBase {
* If used, the content of the file is piped to the remote command * 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 * @param input The file which provides the input data for the remote command
*
* @since Ant 1.8.0
*/ */
public void setInput(File input) { public void setInput(File input) {
inputFile = 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 * 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) { public void setInputProperty(String inputProperty) {
this.inputProperty = 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 * Determines if the output is appended to the file given in
* <code>setOutput</code>. Default is false, that is, overwrite * <code>setOutput</code>. Default is false, that is, overwrite
@@ -174,9 +191,13 @@ public class SSHExec extends SSHBase {
throw new BuildException("Command or commandResource is required."); 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()) { if (inputFile != null && !inputFile.exists()) {
throw new BuildException("The input file " throw new BuildException("The input file "
@@ -254,6 +275,9 @@ public class SSHExec extends SSHBase {
istream = new ByteArrayInputStream(inputData.getBytes()) ; istream = new ByteArrayInputStream(inputData.getBytes()) ;
} }
} }
if (inputString != null) {
istream = new ByteArrayInputStream(inputString.getBytes());
}


try { try {
final ChannelExec channel; final ChannelExec channel;


Loading…
Cancel
Save