diff --git a/bin/cdist-explorer-run b/bin/cdist-explorer-run
index e695424b..0c733e99 100755
--- a/bin/cdist-explorer-run
+++ b/bin/cdist-explorer-run
@@ -18,10 +18,11 @@
# along with cdist. If not, see .
#
#
-# FIXME: This script is ugly, should be either seperated into smaller ones,
-# but definitely be cleaned up - PROOF OF CONCEPT CODE
+# FIXME: Replace * references: * breaks if there is no explorer
+# or FIXME: check that there is at least one explorer?
#
+
. cdist-config
if [ $# -ne 5 ]; then
__cdist_usage " "
@@ -49,17 +50,23 @@ mkdir -p "$__cdist_local_dst_dir"
# FIXME: enable -q as soon as the code is cleaned up
cd "${__cdist_local_src_dir}"
-for explorer in *; do
- # Copy explorers to remote source directory
- scp "${explorer}" \
- "${__cdist_remote_user}@${__cdist_target_host}:${__cdist_remote_src_dir}"
+# Ensure there is at least one explorer
+num="$(ls -1 | wc -l)"
+if [ "$num" -lt 1 ]; then
+ __cdist_exit_err "${__cdist_local_src_dir}: Contains no explorers"
+fi
+
+# Copy all explorers to remote source directory
+scp * "${__cdist_remote_user}@${__cdist_target_host}:${__cdist_remote_src_dir}"
+
+for explorer in *; do
# Execute explorers and save results in remote destination directory
ssh "${__cdist_remote_user}@${__cdist_target_host}" \
- "\"${__cdist_remote_src_dir}/$explorer\" > \
+ "cd \"${__cdist_remote_src_dir}\" && \"./$explorer\" > \
\"${__cdist_remote_dst_dir}/${explorer}\""
-
- # Copy results back to us
- scp "${__cdist_remote_user}@${__cdist_target_host}:${__cdist_remote_dst_dir}/${explorer}" \
- "$__cdist_local_dst_dir/$explorer"
done
+
+# Copy results back to us
+scp "${__cdist_remote_user}@${__cdist_target_host}:${__cdist_remote_dst_dir}/*" \
+ "$__cdist_local_dst_dir"