From 4c1da52f4a7bb71952fa2eaa06b230e9f86ea699 Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Sun, 30 Aug 2026 11:21:54 +0800 Subject: Capture SSH command errors. --- lexd-spool.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lexd-spool.sh b/lexd-spool.sh index 9ce9c3b..c0cf632 100755 --- a/lexd-spool.sh +++ b/lexd-spool.sh @@ -101,9 +101,15 @@ while true; do remote_cmd="${remote_cmd} rm -f" remote_cmd="${remote_cmd} '${SPOOL_DIR}/${SPOOL_FILE}'" - print -r -- "${response}" \ + ssh_err=$(print -r -- "${response}" \ | fold -s -w 72 \ - | ssh -F "${SSH_CONFIG}" "${SSH_HOST}" "${remote_cmd}" + | ssh -F "${SSH_CONFIG}" "${SSH_HOST}" "${remote_cmd}" 2>&1 >/dev/null) + ssh_res=$? + + if [ ${ssh_res} -ne 0 ]; then + log_err "SSH error on ${SPOOL_FILE} (code ${ssh_res}): ${ssh_err}" + exit 1 + fi log_info "Finished processing: ${target_word}" ) -- cgit v1.2.3