diff options
| author | James Pannacciulli <jpnc@jpnc.info> | 2015-01-23 16:18:30 -0800 | 
|---|---|---|
| committer | James Pannacciulli <jpnc@jpnc.info> | 2015-01-26 16:12:03 -0800 | 
| commit | f137425d666429172f990c6a7c5e5af7ab2bf99d (patch) | |
| tree | 686303dc17b56e30a07c7db5449a840e2f0877c8 | |
| parent | 86e1187a63680a2e1a139a33dfa7f73f84528eb7 (diff) | |
| download | parssh-f137425d666429172f990c6a7c5e5af7ab2bf99d.tar.gz parssh-f137425d666429172f990c6a7c5e5af7ab2bf99d.tar.bz2 | |
allow an inner file specification (file to be passed to ssh)WIP
| -rw-r--r-- | pars.sh | 30 | 
1 files changed, 23 insertions, 7 deletions
| @@ -1,6 +1,8 @@  #!/bin/bash  parssh () { +    local origopts=$- +    set -m      while [[ "$1" == -* ]]; do          case ${1#-} in              [0-9]*) @@ -10,29 +12,43 @@ parssh () {                  }              ;;              fo|fouter) -                [[ -f "$2" ]] || { -                    echo "'$2': invalid file name" +                [[ -r "$2" ]] || { +                    echo "'$2': invalid file name or permissions issue"                      return 99                  }                  local parssh_fouter="$2"                  shift                  shift              ;; +            fi|finner) +                [[ -r "$2" ]] || { +                    echo "'$2': invalid file name or permissions issue" +                    return 98 +                } +                local parssh_finner="$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 "$@" & +            sleep 1 +        done +        if [[ -z "$parssh_finner" ]]; then +            ssh -no StrictHostKeyChecking=no $host "$@" & +        else +            ssh -To StrictHostKeyChecking=no $host "$@" < "$parssh_finner" & +        fi      done <&9 +    wait      exec 9>&- +    [[ "${origopts//[^m]/}" == "m" ]] || set +m  } | 
