Re: ITP: dsh -- dancer's shell, or distributed shell.
We had need for something like that here. You're welcome to use all
or part of what I cobbled up, called "sudo-hosts". Under GPL. See below.
Notable feature: allows commands to run in parallel, with output lines
prepended by the appropriate hostname.
I always have an ssh key registered with my ssh agent that allows
password-free execution as root. Otherwise this stuff would be a
serious hassle, and parallel mode wouldn't really work at all.
Another option to consider (I wish someone would package it!) is cssh,
with the accompanying xfanout, fanout, etc. It pops up a whole bunch
of little xterms, each on a different host, and there's an extra
little control window that sends stuff you type to *all* the little
created xterms. Or a subset which can be changed by clicking on some
little radio buttons. See http://www.bitmover.com/bitcluster/ for all
the sources. It's a little rough around the edges, but a really good
idea and it works well enough for routine use.
--Barak.
----------------------------------------------------------------
#!/bin/sh
# CVS version control block - do not edit manually
# $RCSfile: sudo-hosts,v $
# $Revision: 1.9 $
# $Date: 2001/05/15 22:56:19 $
# $Source: /home/cvs/meg/system/sudo-hosts,v $
function usage()
{
PROG=`basename $0`
echo "Usage: $PROG [options] command"
echo
echo "Description: Run given command on a bunch of hosts."
echo
echo "options:"
echo " -h print this help text and exit"
echo " -u user log in as user (default: $user)"
(echo " -r hostlist list of remote hosts (default:";
echo " \"$hosts\")")|fmt -c
echo " -p operate in parallel (background each command)"
}
function docmd () {
h=$2
echo Host: $h
if [ $parallel != 0 ]; then
ssh -n -a -x -l $1 $2 $3 2>&1 | sed "s/^/$h: /" &
else
ssh -a -x -l $1 $2 $3
fi
}
hosts="dandruff phlegm dribble hangnail pus earwax clipping tears toejam loogie flake blood"
offline=""
user=root
parallel=0
while getopts "hr:u:p" opt
do
case "$opt" in
h) usage; exit 0 ;;
u) user="$OPTARG" ;;
r) hosts="$OPTARG" ;;
p) parallel=1 ;;
*) usage; exit 2 ;;
esac
done
shift $((OPTIND - 1))
command="$*"
echo Doing "$command"
for h in $hosts; do
docmd "$user" $h "$command"
done
if [ $parallel != 0 ]; then
wait
fi
Reply to: