Browse Source

Make <sshexec> evaluate the exit code of the remote command.

PR: 19237
Based on a submission by:	Rob Meyer <rob at bigdis dot com>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275151 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
70802b2319
3 changed files with 18 additions and 2 deletions
  1. +2
    -1
      docs/manual/OptionalTasks/scp.html
  2. +2
    -1
      docs/manual/OptionalTasks/sshexec.html
  3. +14
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java

+ 2
- 1
docs/manual/OptionalTasks/scp.html View File

@@ -19,7 +19,8 @@ remote machine.</p>
<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. This task has been tested with jsch-0.1.2 and jsch-0.1.3.</p>
for more information. This task has been tested with jsch-0.1.2 to
jsch-0.1.7.</p>

<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">


+ 2
- 1
docs/manual/OptionalTasks/sshexec.html View File

@@ -18,7 +18,8 @@
<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. This task has been tested with jsch-0.1.3.</p>
for more information. This task has been tested with jsch-0.1.7 and
won't work with earlier versions of jsch..</p>

<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">


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

@@ -214,8 +214,22 @@ public class SSHExec extends SSHBase {
if (outputFile != null) {
writeToFile(out.toString(), append, outputFile);
}

// this is the wrong test if the remote OS is OpenVMS,
// but there doesn't seem to be a way to detect it.
int ec = channel.getExitStatus();
if (ec != 0) {
String msg = "Remote command failed with exit status " + ec;
if (getFailonerror()) {
throw new BuildException(msg);
} else {
log(msg, Project.MSG_ERR);
}
}
}

} catch (BuildException e) {
throw e;
} catch (Exception e) {
if (getFailonerror()) {
throw new BuildException(e);


Loading…
Cancel
Save