aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Pannacciulli <jpnc@jpnc.info>2015-01-23 14:23:56 -0800
committerJames Pannacciulli <jpnc@jpnc.info>2015-01-23 14:23:56 -0800
commit86e1187a63680a2e1a139a33dfa7f73f84528eb7 (patch)
tree2988b5ca71863e14951043f14c3c3188e51b87cd
parent110e5d9e5ebb9237adcc2d4c90ed18d829ed7d28 (diff)
downloadparssh-86e1187a63680a2e1a139a33dfa7f73f84528eb7.tar.gz
parssh-86e1187a63680a2e1a139a33dfa7f73f84528eb7.tar.bz2
allow for more parameters, including ability to read hosts list from file
-rw-r--r--pars.sh32
1 files changed, 28 insertions, 4 deletions
diff --git a/pars.sh b/pars.sh
index 79bc905..4e3544e 100644
--- a/pars.sh
+++ b/pars.sh
@@ -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>&-
}