bodewig 2005/03/14 00:56:48 Modified: . WHATSNEW docs/manual/OptionalTasks rexec.html src/main/org/apache/tools/ant/taskdefs/optional/net RExecTask.java Log: Make <rexec> use the protocol directly, when possible. Also, did the command attribute actually work? PR: 26632 Revision Changes Path 1.772 +3 -0 ant/WHATSNEW Index: WHATSNEW =================================================================== RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.771 retrieving revision 1.772 diff -u -r1.771 -r1.772 --- WHATSNEW 11 Mar 2005 08:41:41 -0000 1.771 +++ WHATSNEW 14 Mar 2005 08:56:48 -0000 1.772 @@ -257,6 +257,9 @@ * 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: ----------- 1.6 +8 -3 ant/docs/manual/OptionalTasks/rexec.html Index: rexec.html =================================================================== RCS file: /home/cvs/ant/docs/manual/OptionalTasks/rexec.html,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- rexec.html 7 Mar 2005 18:11:14 -0000 1.5 +++ rexec.html 14 Mar 2005 08:56:48 -0000 1.6 @@ -17,6 +17,11 @@ <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 @@ <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 @@ <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> 1.12 +32 -13 ant/src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java Index: RExecTask.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- RExecTask.java 11 Mar 2005 15:27:40 -0000 1.11 +++ RExecTask.java 14 Mar 2005 08:56:48 -0000 1.12 @@ -350,23 +350,20 @@ } 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 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); + } + } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]