Browse Source

Make <rexec> use the protocol directly, when possible. Also, did the command attribute actually work? PR: 26632

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277913 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 20 years ago
parent
commit
fa99b4cc44
3 changed files with 43 additions and 16 deletions
  1. +3
    -0
      WHATSNEW
  2. +8
    -3
      docs/manual/OptionalTasks/rexec.html
  3. +32
    -13
      src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java

+ 3
- 0
WHATSNEW View File

@@ -257,6 +257,9 @@ Other changes:
* Ant generated jar files should now be detected as jar files by
Solaris. Bugzilla Report 32649.
* <rexec> with a single command should now work with unusal login
dialogs without special read/write pairs. Bugzilla Report 26632.

Fixed bugs:
-----------



+ 8
- 3
docs/manual/OptionalTasks/rexec.html View File

@@ -17,6 +17,11 @@ it uses nested <tt>&lt;read&gt;</tt> to indicate strings to wait for, and
<p><b>Note:</b> This task depends on external libraries not included in the Ant distribution.
See <a href="../install.html#librarydependencies">Library Dependencies</a> for more information.</p>

<p>You can specify the commands you want to execute as nested elements
or via the command attribute, we recommend you use the command
attribute. If you use the command attribute, you must use the
username and password attributes as well.</p>

<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
@@ -27,12 +32,12 @@ See <a href="../install.html#librarydependencies">Library Dependencies</a> for m
<tr>
<td>userid</td>
<td>the login id to use on the remote server.</td>
<td>Yes</td>
<td>No</td>
</tr>
<tr>
<td>password</td>
<td>the login password to use on the remote server.</td>
<td>Yes</td>
<td>No</td>
</tr>
<tr>
<td>server</td>
@@ -42,7 +47,7 @@ See <a href="../install.html#librarydependencies">Library Dependencies</a> for m
<tr>
<td>command</td>
<td>the command to execute on the remote server.</td>
<td>Yes</td>
<td>No</td>
</tr>
<tr>
<td>port</td>


+ 32
- 13
src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java View File

@@ -350,23 +350,20 @@ public class RExecTask extends Task {
} catch (IOException e) {
throw new BuildException("Can't connect to " + server);
}
/** Login if userid and password were specified */
if (userid != null && password != null) {
login(rexec);
}
/** Process each sub command */
Enumeration tasksToRun = rexecTasks.elements();
while (tasksToRun != null && tasksToRun.hasMoreElements()) {
RExecSubTask task = (RExecSubTask) tasksToRun.nextElement();
if (task instanceof RExecRead && defaultTimeout != null) {
((RExecRead) task).setDefaultTimeout(defaultTimeout);
}
task.execute(rexec);
if (userid != null && password != null && command != null
&& rexecTasks.size() == 0) {
// simple one-shot execution
rexec.rexec(userid, password, command);
} else {
// need nested read/write elements
handleMultipleTasks(rexec);
}

/** Keep reading input stream until end of it or time-out */
rexec.waitForEOF(defaultTimeout);
} finally {
} catch (IOException e) {
throw new BuildException("Error r-executing command", e);
} finally {
if (rexec != null && rexec.isConnected()) {
try {
rexec.disconnect();
@@ -446,4 +443,26 @@ public class RExecTask extends Task {
public void setUserid(String u) {
this.userid = u;
}

/**
* Deals with multiple read/write calls.
*
* @since Ant 1.6.3
*/
private void handleMultipleTasks(AntRExecClient rexec) {

/** Login if userid and password were specified */
if (userid != null && password != null) {
login(rexec);
}
/** Process each sub command */
Enumeration tasksToRun = rexecTasks.elements();
while (tasksToRun != null && tasksToRun.hasMoreElements()) {
RExecSubTask task = (RExecSubTask) tasksToRun.nextElement();
if (task instanceof RExecRead && defaultTimeout != null) {
((RExecRead) task).setDefaultTimeout(defaultTimeout);
}
task.execute(rexec);
}
}
}

Loading…
Cancel
Save