xref: /onnv-gate/usr/src/cmd/bnu/uuto (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!/bin/sh
2*0Sstevel@tonic-gate#
3*0Sstevel@tonic-gate# CDDL HEADER START
4*0Sstevel@tonic-gate#
5*0Sstevel@tonic-gate# The contents of this file are subject to the terms of the
6*0Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only
7*0Sstevel@tonic-gate# (the "License").  You may not use this file except in compliance
8*0Sstevel@tonic-gate# with the License.
9*0Sstevel@tonic-gate#
10*0Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11*0Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
12*0Sstevel@tonic-gate# See the License for the specific language governing permissions
13*0Sstevel@tonic-gate# and limitations under the License.
14*0Sstevel@tonic-gate#
15*0Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
16*0Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17*0Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
18*0Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
19*0Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
20*0Sstevel@tonic-gate#
21*0Sstevel@tonic-gate# CDDL HEADER END
22*0Sstevel@tonic-gate#
23*0Sstevel@tonic-gate#
24*0Sstevel@tonic-gate# Copyright 1995 Sun Microsystems, Inc.  All rights reserved.
25*0Sstevel@tonic-gate# Use is subject to license terms.
26*0Sstevel@tonic-gate#
27*0Sstevel@tonic-gate#ident	"%Z%%M%	%I%	%E% SMI"
28*0Sstevel@tonic-gate#
29*0Sstevel@tonic-gateuuto () {
30*0Sstevel@tonic-gatef=""
31*0Sstevel@tonic-gated=""
32*0Sstevel@tonic-gateerror="0"
33*0Sstevel@tonic-gate#	get file names
34*0Sstevel@tonic-gate#	files must be readable,
35*0Sstevel@tonic-gate#	directories must be readable/searchable
36*0Sstevel@tonic-gate#	otherwise increment error count and skip it.
37*0Sstevel@tonic-gatewhile test $#  -ge 1
38*0Sstevel@tonic-gatedo
39*0Sstevel@tonic-gate	if test -d "$1" -a {"$1" = "." -o "$1" = ".."}
40*0Sstevel@tonic-gate		then shift; continue
41*0Sstevel@tonic-gate	elif test -r "$1" -a -f "$1"
42*0Sstevel@tonic-gate		then f="$f $1"
43*0Sstevel@tonic-gate	elif test -r "$1" -a -x "$1" -a -d "$1"
44*0Sstevel@tonic-gate		then d="$d $1"
45*0Sstevel@tonic-gate	else error=`expr 0$error + 1`
46*0Sstevel@tonic-gate		if test -f "$1"; then
47*0Sstevel@tonic-gate			printf "`gettext 'uuto: %s%s: file not readable'`\n" $UUP $1 >&2
48*0Sstevel@tonic-gate		elif test -d "$1"; then
49*0Sstevel@tonic-gate			printf "`gettext 'uuto: %s%s: directory not readable/searchable'`\n" $UUP $1 >&2
50*0Sstevel@tonic-gate		else
51*0Sstevel@tonic-gate			printf "`gettext 'uuto: %s%s: file/directory not found'`\n" $UUP $1 >&2
52*0Sstevel@tonic-gate		fi
53*0Sstevel@tonic-gate	fi
54*0Sstevel@tonic-gate	shift
55*0Sstevel@tonic-gatedone
56*0Sstevel@tonic-gateif test -n "$d" -a -n "$user"
57*0Sstevel@tonic-gatethen
58*0Sstevel@tonic-gate	for i in $d
59*0Sstevel@tonic-gate	do
60*0Sstevel@tonic-gate		( cd $i; UUP="$UUP$i/"
61*0Sstevel@tonic-gate		uuto * $1)
62*0Sstevel@tonic-gate		error=`expr 0$error + 0$?`
63*0Sstevel@tonic-gate	done
64*0Sstevel@tonic-gatefi
65*0Sstevel@tonic-gate
66*0Sstevel@tonic-gateif test -n "$f" -a -n "$user"
67*0Sstevel@tonic-gatethen
68*0Sstevel@tonic-gate	uucp $a $f $remote!~/receive/$user/$mysys/$UUP
69*0Sstevel@tonic-gate	error=`expr 0$error + 0$?`
70*0Sstevel@tonic-gatefi
71*0Sstevel@tonic-gate
72*0Sstevel@tonic-gatereturn $error
73*0Sstevel@tonic-gate}
74*0Sstevel@tonic-gate
75*0Sstevel@tonic-gate# main uuto shell
76*0Sstevel@tonic-gate
77*0Sstevel@tonic-gateexport IFS PATH
78*0Sstevel@tonic-gateIFS="
79*0Sstevel@tonic-gate"
80*0Sstevel@tonic-gatePATH="/usr/bin"
81*0Sstevel@tonic-gate
82*0Sstevel@tonic-gatea=""
83*0Sstevel@tonic-gatetemp=""
84*0Sstevel@tonic-gatemysys=`uuname -l`
85*0Sstevel@tonic-gatemesg="Usage: uuto [-mp] files remote!user\n"
86*0Sstevel@tonic-gate
87*0Sstevel@tonic-gatetrap "trap '' 0; exit $?" 1 2 3 13 15
88*0Sstevel@tonic-gatecopy=0
89*0Sstevel@tonic-gate#	get options
90*0Sstevel@tonic-gatewhile getopts mp FLAG; do
91*0Sstevel@tonic-gate	case $FLAG in
92*0Sstevel@tonic-gate	m)	a="$a -m"
93*0Sstevel@tonic-gate		;;
94*0Sstevel@tonic-gate	p)	a="$a -C"
95*0Sstevel@tonic-gate		copy=1 ;;
96*0Sstevel@tonic-gate	?)	gettext "$mesg" >&2
97*0Sstevel@tonic-gate		exit 1
98*0Sstevel@tonic-gate		;;
99*0Sstevel@tonic-gate	esac
100*0Sstevel@tonic-gatedone
101*0Sstevel@tonic-gateshift `expr $OPTIND - 1`
102*0Sstevel@tonic-gate
103*0Sstevel@tonic-gate#	be sure have both files and destination
104*0Sstevel@tonic-gateif test $# -lt 2
105*0Sstevel@tonic-gatethen
106*0Sstevel@tonic-gate	gettext "$mesg" >&2
107*0Sstevel@tonic-gate	exit 1
108*0Sstevel@tonic-gatefi
109*0Sstevel@tonic-gate#	skip file names to get to destination
110*0Sstevel@tonic-gatewhile test $#  -gt 1
111*0Sstevel@tonic-gatedo
112*0Sstevel@tonic-gate	temp="$temp $1"
113*0Sstevel@tonic-gate	shift
114*0Sstevel@tonic-gatedone
115*0Sstevel@tonic-gate#	the recipient arg: remote!user
116*0Sstevel@tonic-gate#	remote may be omitted (default is this machine)
117*0Sstevel@tonic-gate#	must have at least !user
118*0Sstevel@tonic-gateremote=`expr $1 : '\(.*\)!'`
119*0Sstevel@tonic-gateuser=`expr $1 : '.*!\(.*\)'`
120*0Sstevel@tonic-gateif test -z "$user"
121*0Sstevel@tonic-gatethen
122*0Sstevel@tonic-gate	gettext "uuto: incomplete destination -- must specify user\n" >&2
123*0Sstevel@tonic-gate	gettext "$mesg" >&2
124*0Sstevel@tonic-gate	exit 1
125*0Sstevel@tonic-gatefi
126*0Sstevel@tonic-gatea="$a -d -n $user"
127*0Sstevel@tonic-gate
128*0Sstevel@tonic-gateUUP=""
129*0Sstevel@tonic-gateuuto $temp
130*0Sstevel@tonic-gate
131*0Sstevel@tonic-gateexit $error
132