diff options
author | Jim Pannacciulli <jpannacciulli@mediatemple.net> | 2015-07-23 14:01:35 -0700 |
---|---|---|
committer | Jim Pannacciulli <jpannacciulli@mediatemple.net> | 2015-07-23 14:01:35 -0700 |
commit | 568aefc98e7ec7b5bab8d09f3b560c72d4d6066a (patch) | |
tree | 9e0c7c298945d346c04091db2d838156bae0a3b8 /pars.sh | |
parent | 2051725c4a7718911bbc11f1e29d284e6933d333 (diff) | |
download | parssh-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.sh | 30 |
1 files changed, 22 insertions, 8 deletions
@@ -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 |