#!sh
# HPUX_ID: @(#)27.2   86/03/07
#          @(#)uuto.sh	27.2      85/10/10
#*****************************************************************
#*    (c) Copyright 1983 Hewlett Packard Co.
#*        ALL RIGHTS RESERVED
#*****************************************************************/


#
#########################################################################
#   HISTORY:
#
#   03-18-83	Modify test of variable copy to include an else clause to
#		invoke the -C option of uucp. This is the correct option
#		to use the -p uuto option. Also added explicit path 
#		statement.
#########################################################################
#
PATH=/bin:/usr/bin:/etc:.:/rom
export PATH
mysys=`uname -n`
mesg="Usage: $0 [-m -p] files remote!user"
if test  $# -lt 1
	then
		echo $mesg
		exit
fi
trap "trap '' 0; exit" 0 1 2 13 15
copy=""
#	get options
while true
do
	case $1 in
	 -m | -r* | -x*)	a="$a $1" ;;
	 -p)	copy=1 ;;
	 -d | -n*)	;;
	 -*)	echo $mesg; exit;;
	 *)	break ;;
	esac
	shift
done
#	get file names
while test $#  -gt 1
do
	if test -r "$1" -a -f "$1"
		then f="$f $1"
	elif test -r "$1" -a -d "$1"
		then d="$d $1"
		elif test "$UUP" = ""
		then echo "$1: file/directory not found"; exit
	fi
	shift
done
#	the recipient arg: remote!user
remote=`expr $1 : '\(.*\)!'`
user=`expr $1 : '.*!\(.*\)' \| $1`
if test -z "$copy"
then
	a="$a -c"
else
	a="$a -C"
fi
	a="$a -d -n$user"
error=1
if test -n "$d" -a -n "$user"
then
	for i in $d
	do
	( cd $i; UUP="$UUP/$i" uuto * $1 )
	error=0
	done
fi
if test -n "$f" -a -n "$user"
then
	uucp $a $f $remote!~/receive/$user/$mysys$UUP/
	error=0
fi
if test error = 1
then 
	echo $mesg
	exit 2
fi
