diff options
Diffstat (limited to 'pars.sh')
-rw-r--r-- | pars.sh | 32 |
1 files changed, 28 insertions, 4 deletions
@@ -1,14 +1,38 @@ #!/bin/bash parssh () { - [[ "$1" == -[0-9]* && "$1" != *[^0-9-]* ]] && { - local parssh_concurrency=${1#-} - shift + while [[ "$1" == -* ]]; do + case ${1#-} in + [0-9]*) + [[ "${1#-}" != *[^0-9]* ]] && { + local parssh_concurrency=${1#-} + shift + } + ;; + fo|fouter) + [[ -f "$2" ]] || { + echo "'$2': invalid file name" + return 99 + } + local parssh_fouter="$2" + shift + shift + ;; + esac + done + + [[ -z "$parssh_fouter" ]] && { + exec 9<&0 + } || { + echo "reading $parssh_fouter" + exec 9<"$parssh_fouter" } + while read host; do while (( $(jobs -pr | wc -l) >= ${parssh_concurrency:-4} )); do sleep 1; done; ssh -no StrictHostKeyChecking=no $host "$@" & - done + done <&9 + exec 9>&- } |