diff --git a/docs/manual/OptionalTasks/scp.html b/docs/manual/OptionalTasks/scp.html
index a84d0e0a9..29892be4b 100644
--- a/docs/manual/OptionalTasks/scp.html
+++ b/docs/manual/OptionalTasks/scp.html
@@ -19,7 +19,8 @@ remote machine.
Note: This task depends on external libraries not included
in the Ant distribution. See Library Dependencies
-for more information. This task has been tested with jsch-0.1.2 and jsch-0.1.3.
+for more information. This task has been tested with jsch-0.1.2 to
+jsch-0.1.7.
Parameters
diff --git a/docs/manual/OptionalTasks/sshexec.html b/docs/manual/OptionalTasks/sshexec.html
index a55f91efe..4b8d35b50 100644
--- a/docs/manual/OptionalTasks/sshexec.html
+++ b/docs/manual/OptionalTasks/sshexec.html
@@ -18,7 +18,8 @@
Note: This task depends on external libraries not included
in the Ant distribution. See Library Dependencies
-for more information. This task has been tested with jsch-0.1.3.
+for more information. This task has been tested with jsch-0.1.7 and
+won't work with earlier versions of jsch..
Parameters
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 32ed56f7f..41529abcd 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
@@ -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);