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