aboutsummaryrefslogtreecommitdiffstats
path: root/pars.sh
diff options
context:
space:
mode:
authorJim Pannacciulli <jpannacciulli@mediatemple.net>2015-07-23 14:01:35 -0700
committerJim Pannacciulli <jpannacciulli@mediatemple.net>2015-07-23 14:01:35 -0700
commit568aefc98e7ec7b5bab8d09f3b560c72d4d6066a (patch)
tree9e0c7c298945d346c04091db2d838156bae0a3b8 /pars.sh
parent2051725c4a7718911bbc11f1e29d284e6933d333 (diff)
downloadparssh-568aefc98e7ec7b5bab8d09f3b560c72d4d6066a.tar.gz
parssh-568aefc98e7ec7b5bab8d09f3b560c72d4d6066a.tar.bz2
Add '-C' option to include remote command / metadata in output
Diffstat (limited to 'pars.sh')
-rw-r--r--pars.sh30
1 files changed, 22 insertions, 8 deletions
diff --git a/pars.sh b/pars.sh
index 02d1c01..597de31 100644
--- a/pars.sh
+++ b/pars.sh
@@ -46,6 +46,9 @@ parssh () {
local _parssh_ssh_config="$2"
shift
;;
+ C|-savecmd)
+ local _parssh_savecmd="true"
+ ;;
h|-help)
_parssh.usage
return $?
@@ -99,14 +102,25 @@ parssh () {
exec 9<"$_parssh_servers"
}
- while read host; do
- while (( $(jobs -pr | wc -l) >= ${_parssh_concurrency:-4} )); do
- sleep 1
- done
- $_parssh_ssh "$@" 2> >(_parssh.host_prepend >&2) |\
- _parssh.host_prepend &
- done <&9 2> >($_parssh_outfun err >&2) |\
- $_parssh_outfun out
+ {
+ [[ "$_parssh_savecmd" == "true" ]] && {
+ printf "### ###\n"
+ printf "### %s: %s\n"\
+ date "$(date +%F@%R%z)"\
+ user "$USER($UID)"\
+ pwd "$PWD"
+ printf "### BEGIN parssh remote commands ###\n"
+ printf "%s\n### END parssh remote commands ###\n### ###\n"\
+ "$@"
+ }
+ while read host; do
+ while (( $(jobs -pr | wc -l) >= ${_parssh_concurrency:-4} )); do
+ sleep 1
+ done
+ $_parssh_ssh "$@" 2> >(_parssh.host_prepend >&2) |\
+ _parssh.host_prepend &
+ done <&9 2> >($_parssh_outfun err >&2)
+ } | $_parssh_outfun out
wait