Multiple machine rcp script for 4.2BSD
Chris Torek
chris at umcp-cs.UUCP
Sun Mar 31 18:34:04 AEST 1985
This shell script can come in handy for updating files on multiple
machines in 4.2BSD networked environments. It's no substitute for a
real remote file system, but it gets the job done . . . . All you need
to do to it is edit the default list of machines.
#! /bin/sh
#
# rrcp - do a complete rcp (to all local machines)
# 30 March 1985, Chris Torek, University of Maryland
# hacked up from Bruce Israel's original version
# This code is careful not to invoke extra programs for non-sysV "sh"s
usage='echo "usage: $0 [-h hosts] f1 [f2] (copy f1 to f2)
or: $0 [-h hosts] f1 f2 ... fn dir (copy files to directory)" 1>&2; exit 1'
hosts="mimsy tove gymble gyre"
case "$1" in
-h) hosts="$2"; shift 2;;
esac
case $# in
0) eval "$usage";;
1) from="$1"; to="$1"; type=normal;;
*) eval "dir=\"$`echo $#`\"" # effectively, dir = $($#)
if [ -d "$dir" ]; then
type=directory
else
case $# in
2) from="$1"; to="$2"; type=normal;;
*) eval "$usage";;
esac
fi;;
esac
# Have established credentials of given arguments. Now make a temporary
# copy of the original file (so that, e.g., "rcp mimsy:xyzzy mimsy:xyzzy"
# never happens, since that makes rcp clobber the file), then send it
# around.
temp=/tmp/rrcp.$$
trap 'rm -f $temp; exit' 0 1 2 3 15
case $type in
normal)
rcp "$from" $temp
for machine in $hosts; do
echo "rcp $from $machine:$to"
rcp $temp "$machine:$to"
done;;
directory)
for from in "$@"; do
case $# in
1) ;;
*) rcp "$from" $temp
for machine in $hosts; do
echo "rcp $from $machine:$dir"
rcp $temp "$machine:$dir"
done;;
esac
shift
done;;
*)
echo "BUG: type=$type" 1>&2; exit 1;;
esac
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP: {seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet: chris at umcp-cs ARPA: chris at maryland
More information about the Comp.sources.unix
mailing list