From 70802b2319e95db5b1f4bcab9247da14856a3bd8 Mon Sep 17 00:00:00 2001
From: Stefan Bodewig
Date: Thu, 28 Aug 2003 07:10:40 +0000
Subject: [PATCH] Make evaluate the exit code of the remote command.
PR: 19237
Based on a submission by: Rob Meyer
git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275151 13f79535-47bb-0310-9956-ffa450edef68
---
docs/manual/OptionalTasks/scp.html | 3 ++-
docs/manual/OptionalTasks/sshexec.html | 3 ++-
.../tools/ant/taskdefs/optional/ssh/SSHExec.java | 14 ++++++++++++++
3 files changed, 18 insertions(+), 2 deletions(-)
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);