aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Pannacciulli <jpnc@jpnc.info>2015-01-27 10:39:07 -0800
committerJames Pannacciulli <jpnc@jpnc.info>2015-01-27 10:39:07 -0800
commiteb76f99f7011edcaf33795b32b0e9cd6f5b8db1c (patch)
tree39cce7f7d3ab3929f306f2745821daa17639156a
parentf137425d666429172f990c6a7c5e5af7ab2bf99d (diff)
downloadparssh-eb76f99f7011edcaf33795b32b0e9cd6f5b8db1c.tar.gz
parssh-eb76f99f7011edcaf33795b32b0e9cd6f5b8db1c.tar.bz2
Add prepend_host flag so we can know which output came from which host
also consolidate shifts in option-parsing case loop
-rw-r--r--pars.sh16
1 files changed, 11 insertions, 5 deletions
diff --git a/pars.sh b/pars.sh
index 819153b..f6741b7 100644
--- a/pars.sh
+++ b/pars.sh
@@ -8,7 +8,6 @@ parssh () {
[0-9]*)
[[ "${1#-}" != *[^0-9]* ]] && {
local parssh_concurrency=${1#-}
- shift
}
;;
fo|fouter)
@@ -18,7 +17,6 @@ parssh () {
}
local parssh_fouter="$2"
shift
- shift
;;
fi|finner)
[[ -r "$2" ]] || {
@@ -27,9 +25,12 @@ parssh () {
}
local parssh_finner="$2"
shift
- shift
+ ;;
+ p|prepend_host)
+ local parssh_prepend_host=true
;;
esac
+ shift
done
[[ -z "$parssh_fouter" ]] && {
@@ -43,12 +44,17 @@ parssh () {
sleep 1
done
if [[ -z "$parssh_finner" ]]; then
- ssh -no StrictHostKeyChecking=no $host "$@" &
+ ssh -no StrictHostKeyChecking=no $host "$@" | host_prepend &
else
- ssh -To StrictHostKeyChecking=no $host "$@" < "$parssh_finner" &
+ ssh -To StrictHostKeyChecking=no $host "$@" < "$parssh_finner" | host_prepend &
fi
done <&9
wait
exec 9>&-
[[ "${origopts//[^m]/}" == "m" ]] || set +m
}
+
+host_prepend ()
+ while read -r; do
+ printf "${parssh_prepend_host+$host: }%s\n" "$REPLY"
+ done