Removed -o pipefail.
[xremote.git] / xremote.sh
index dca62c6..ce16636 100755 (executable)
@@ -18,7 +18,8 @@
 #########################################################################
 
 set -e
 #########################################################################
 
 set -e
-set -o pipefail
+
+# set -o pipefail
 
 ######################################################################
 
 
 ######################################################################
 
@@ -40,8 +41,8 @@ xremote.sh <script>
   temporary directory on a ssh-accessible server.
 
   It parses the script first to find embedded arguments which defines
   temporary directory on a ssh-accessible server.
 
   It parses the script first to find embedded arguments which defines
-  the hostname on which to run it, the files to send, the files to
-  get back when the execution is done, and commands to execute before
+  the hostname on which to run, the files to send, the files to get
+  back when the execution is over, and commands to execute before
   running the executable remotely.
 
   These arguments can appear multiple times, except the one that
   running the executable remotely.
 
   These arguments can appear multiple times, except the one that
@@ -97,17 +98,20 @@ do
 
             EXEC)
                 check_remote_is_defined
 
             EXEC)
                 check_remote_is_defined
+                [[ "${REMOTE_EXEC}" ]] && (exit "Remote executable already defined!" >&2 && exit 1)
                 REMOTE_EXEC="${value}"
                 ;;
 
             PRE)
                 check_remote_is_defined
                 REMOTE_EXEC="${value}"
                 ;;
 
             PRE)
                 check_remote_is_defined
+                echo "xremote: ${value}"
                 ssh < /dev/null "${REMOTE_HOST}" "cd \"${REMOTE_DIR}\" && ${value}"
                 ;;
 
             SEND)
                 check_remote_is_defined
                 ssh < /dev/null "${REMOTE_HOST}" "cd \"${REMOTE_DIR}\" && ${value}"
                 ;;
 
             SEND)
                 check_remote_is_defined
-                tar c ${value} | ssh "${REMOTE_HOST}" "cd \"${REMOTE_DIR}\" && tar mx"
+                echo "xremote: -- sending files --------------------------------------------"
+                tar ch ${value} | ssh "${REMOTE_HOST}" "cd \"${REMOTE_DIR}\" && tar mxv"
                 ;;
 
             HOST)
                 ;;
 
             HOST)
@@ -116,6 +120,7 @@ do
                 [[ "${REMOTE_HOST}" ]] || REMOTE_HOST="${XREMOTE_HOST}"
                 [[ "${REMOTE_HOST}" ]] || (echo "xremote: No remote host specified." >&2 && exit 1)
                 REMOTE_DIR="$(ssh </dev/null "${REMOTE_HOST}" mktemp -d /tmp/xremote.from_"$(hostname)_$(date +%Y%m%d-%H%M%S)".XXXXXX)"
                 [[ "${REMOTE_HOST}" ]] || REMOTE_HOST="${XREMOTE_HOST}"
                 [[ "${REMOTE_HOST}" ]] || (echo "xremote: No remote host specified." >&2 && exit 1)
                 REMOTE_DIR="$(ssh </dev/null "${REMOTE_HOST}" mktemp -d /tmp/xremote.from_"$(hostname)_$(date +%Y%m%d-%H%M%S)".XXXXXX)"
+                echo "xremote: target is ${REMOTE_HOST}"
                 ;;
         esac
     fi
                 ;;
         esac
     fi
@@ -128,7 +133,7 @@ check_remote_is_defined
 
 tar c "${main}" | ssh "${REMOTE_HOST}" "cd \"${REMOTE_DIR}\" && tar mx"
 
 
 tar c "${main}" | ssh "${REMOTE_HOST}" "cd \"${REMOTE_DIR}\" && tar mx"
 
-echo "xremote: on ${REMOTE_HOST}"
+echo "xremote: -- running the executable -----------------------------------"
 
 if [[ "${REMOTE_EXEC}" ]]
 then
 
 if [[ "${REMOTE_EXEC}" ]]
 then
@@ -137,14 +142,13 @@ else
     REMOTE_COMMAND="./${main}"
 fi
 
     REMOTE_COMMAND="./${main}"
 fi
 
-echo "xremote: -- stdout ---------------------------------------------------"
 ssh </dev/null "${REMOTE_HOST}" "cd \"${REMOTE_DIR}\" && ${REMOTE_COMMAND}"
 
 ######################################################################
 
 # Disable globbing to keep wildcards for the remote side
 
 ssh </dev/null "${REMOTE_HOST}" "cd \"${REMOTE_DIR}\" && ${REMOTE_COMMAND}"
 
 ######################################################################
 
 # Disable globbing to keep wildcards for the remote side
 
-echo "xremote: -- retrieve results -----------------------------------------"
+echo "xremote: -- retrieving files -----------------------------------------"
 
 set -f
 
 
 set -f