diff options
-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 |