diff --git a/src/usr/local/bin/validate_workflow.sh b/src/usr/local/bin/validate_workflow.sh
index 8f4a6c88751083a45cd1ad9a173f98f3c331de9f..3b3afa70ff4de82e40d519d6de7cdc7734d73422 100755
--- a/src/usr/local/bin/validate_workflow.sh
+++ b/src/usr/local/bin/validate_workflow.sh
@@ -74,9 +74,9 @@ FILES_MODE_LIST="sort,delete,nothing"
 # DEFAULTS
 WITH_DAEMON=0
 WITH_DEBUG=0
-WITH_PIPE=0
-STAGE=any
-MODE=auto
+export WITH_PIPE=0
+export STAGE=any
+export MODE=auto
 FILES_MODE=nothing
 STATFILE=${HOME}/.cache/validate_workflows/statistics.cnt
 LOCKFILE=/var/lock/validate_workflows.lock
@@ -221,6 +221,12 @@ get_mimetype() {
     echo "${res}"
 }
 
+echo_validation_result_if_pipe() {
+    local is_valid="$1"
+    if [[ "${WITH_PIPE}" -eq 1 ]]; then
+      echo "${is_valid}"
+    fi
+}
 
 get_cli_args() {
     local lines
@@ -372,7 +378,7 @@ prepare_cmd() {
         echo "${cmd}"
     else
         debug "no valid command found using key ${key}"
-        echo "echo 'no validation tool detected!'"
+        error "No validation tool detected!"
     fi
 }
 
@@ -509,6 +515,30 @@ get_logfile() {
     echo "${logname}"
 }
 
+run_validation_cmd() {
+    local mode="$1"
+    local mimetype="$2"
+    local ftype="$3"
+    local stage="$4"
+    local filename="$5"
+    local logname="$6"
+    local cmd
+    local cmd_exitcode
+    local is_valid
+    cmd=$(prepare_cmd "${mode}" "${ftype}" "${stage}") # has FILE placeholder
+    cmd_exitcode=$?
+    debug "cmd: ${cmd}"
+    debug "cmd_exitcode: ${cmd_exitcode}"
+    if [[ "${cmd_exitcode}" -eq 1 ]]; then
+        is_valid="1" # invalid, prepare cmd failed
+        echo "Failed to build validation command from stage '${stage}', mode '${mode}', mimetype '${mimetype}', mapped file type '${ftype}'" >> "${logname}"
+    else
+        cmd=$(echo "${cmd}" | sed -e "s#FILE#${filename}#") # replace FILE placeholder
+        is_valid=$(exec_cmd "${cmd}" "${ftype}" "${mode}" "${stage}" "${logname}")
+    fi
+    debug "run_validation_cmd, is_valid: ${is_valid}"
+    echo "${is_valid}"
+}
 
 scan_file() {
     check_argument_count $# 1
@@ -535,8 +565,7 @@ scan_file() {
     if [[ "${STAGE}" = "any" ]]; then
         is_valid=1
         for stage in upcoming current; do
-            cmd=$(prepare_cmd "${MODE}" "${ftype}" "${stage}" | sed -e "s#FILE#${filename}#")
-            is_valid=$(exec_cmd "${cmd}" "${ftype}" "${MODE}" "${stage}" "${logname}")
+            is_valid=$(run_validation_cmd "${MODE}" "${mimetype}" "${ftype}" "${stage}" "${filename}" "${logname}") # stage set by loop
             if [[ "${is_valid}" -eq 0 ]]; then
                 debug "scan_file, early break"
                 break
@@ -546,13 +575,13 @@ scan_file() {
         done
         handle_input_if_requested "${filename}" "${is_valid}"
     else
-        cmd=$(prepare_cmd "${MODE}" "${ftype}" "${STAGE}" | sed -e "s#FILE#${filename}#")
-        is_valid=$(exec_cmd "${cmd}" "${ftype}" "${MODE}" "${STAGE}" "${logname}")
+        is_valid=$(run_validation_cmd "${MODE}" "${mimetype}" "${ftype}" "${STAGE}" "${filename}" "${logname}") # stage set by user
         handle_input_if_requested "${filename}" "${is_valid}"
     fi
     debug "scan_file, === leaving protected area ==="
     trap - SIGINT
     debug "---"
+    echo_validation_result_if_pipe "${is_valid}"
 }
 
 scan_dir() {
@@ -572,10 +601,12 @@ if [[ "${WITH_PIPE}" -eq 1 ]]; then
     debug "checking stream"
     filename=$(mktemp --tmpdir validate_wrg.XXXX)
     cat - > "${filename}"
-    scan_file "${filename}"
+    result=$(scan_file "${filename}")
+    debug "pipe mode result (is_valid): ${result}"
     cat "${filename}.log"
     rm -f "${filename}.log" || error "could not remove temporary file '${filename}.log'"
     rm -f "${filename}" || error "could not remove temporary file '${filename}'"
+    exit "${result}"
 else 
     if [[ "${WITH_DAEMON}" -eq 1 ]]; then
         # TODO: protect DAEMON from STRG-C for clean shutdown