Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/bash
- # usage: ./mass_command <computer(s)> <command>
- # path that is per-computer
- COMP_PATH='/localdisk/boinc';
- #---
- # replace ',' with ' ' so that we can easily iterate
- computers=`echo $1 | sed -e 's/,/ /g'`
- # these are the computer names for my network, for demonstration:
- all_majors='tabletop blake macomb cascade phelps colden porter marcy seward nye sawteeth'
- all_minors='skylight armstrong cliff gothics hough haystack iroquois colvin panther algonquin wright marshall redfield whiteface'
- all_servers='cycle1 cycle2 cycle3'
- all_clients="$all_majors $all_minors"
- all_computers="$all_servers $all_clients"
- # if one of these matches, use that list instead of keyword; switch should have been used here...
- if [ "$computers" == "all" ]
- then
- computers=$all_computers
- fi
- if [ "$computers" == 'majors' ]
- then
- computers=$all_majors
- fi
- if [ "$computers" == 'minors' ]
- then
- computers=$all_minors
- fi
- if [ "$computers" == 'clients' ]
- then
- computers=$all_clients
- fi
- if [ "$computers" == 'servers' ]
- then
- computers=$all_servers
- fi
- # remove $1 from $@ -> $args
- args=`echo $@ | sed -e "s/$1 //"`
- # iterate over $computers and run $args in $COMP_PATH
- # NOTE: this makes '.' mean something different in argument to this program vs. when calling this program!
- for C in $computers
- do
- echo "Running '$args' on $C:"
- ssh $C "cd $COMP_PATH; $args"
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement