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