#!/bin/bsh # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # bos720 src/bos/usr/bin/uucp/uupick 1.9 # # Licensed Materials - Property of IBM # # COPYRIGHT International Business Machines Corp. 1985,1989 # All Rights Reserved # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # IBM_PROLOG_END_TAG # COMPONENT_NAME: UUCP uupick # # FUNCTIONS: # # ORIGINS: 10 27 3 # # (C) COPYRIGHT International Business Machines Corp. 1985, 1989 # All Rights Reserved # Licensed Materials - Property of IBM # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # @(#)37 1.9 src/bos/usr/bin/uucp/uupick, cmduucp, bos720 5/19/08 01:53:30 # # uupick.sh 1.3 # sys: system; user: login name; cdir: current directory; # tdir: temporary directory; pu: PUBDIR/receive/user; PATH=/usr/bin:/usr/sbin:$PATH export PATH cdir=`pwd` dir="" abs="" sys="" trap "exit" 1 2 13 15 CMD=`basename $0` Usage="Usage: $CMD [-s sysname]" # get options if test $# -eq 1 then echo $Usage >&2; exit 1 fi while test $# -gt 1 do case $1 in -s) sys=$2 ;; *) echo $Usage >&2; exit 1 esac shift; shift done user=`id | sed -n "/^uid=[0-9]*(\([^)]*\)).*/s//\1/p"` if test -z "$user" then echo "User id required!" >&2; exit 1 fi pu=/usr/spool/uucppublic/receive/$user if test -d $pu -a -s $pu then for i in `ls $pu` do if test $sys then if test $sys != $i; then continue; fi fi if test -d $pu/$i -a -s $pu/$i then cd $pu/$i for j in `ls -a` do if test $j = "." -o $j = ".."; then continue; fi if test -d $j then echo "from system $i: directory $j" else echo "from system $i: file $j" fi while true do echo '?' if read cmd dir then trap ": ;;" 1 eval dir=$dir case $cmd in d) rm -fr $j ; break ;; "") break ;; #options m, a: if dir path #begins with a slash, use full #path for destination;otherwise, #use path relative to current dir; #default destination is current dir m) if test $dir then abs=`expr "$dir" : '/.*'` if test $abs != 0 then tdir=$dir else tdir=$cdir/$dir fi else tdir=$cdir fi if [ ! -d $tdir -o ! -w $tdir ]; then echo "directory '$tdir' doesn't exist or isn't writable" >&2 continue fi find $j -print |cpio -pdmuv $tdir \ 1>> /tmp/$$uupick for k in `cat /tmp/$$uupick` do var=`echo $k |sed -n "s;^$tdir/;;p"` var="$pu/$i/$var" rm -fr $var done if test $j -eq 0 then rm -fr $j fi rm -f /tmp/$$uupick break;; #As files are transferred, #put their names in /tmp/$$uupick. #Only remove those named files #from...receive/..dir a) if test $dir then abs=`expr "$dir" : '/.*'` if test $abs != 0 then tdir=$dir else tdir=$cdir/$dir fi else tdir=$cdir fi if [ ! -d $tdir -o ! -w $tdir ]; then echo "directory '$tdir' doesn't exist or isn't writable" >&2 continue fi find * -print |\ cpio -pdmuv $tdir 1>> /tmp/$$uupick for k in `cat /tmp/$$uupick` do var=`echo $k |sed -n "s;^$tdir/;;p"` var="$pu/$i/$var" rm -fr $var done if test $j -eq 0 then rm -fr $j fi rm -f /tmp/$$uupick break 2 ;; p) if test -d $j then find . -print elif test -s $j then cat $j fi ;; q) break 3 ;; !*) ex=`expr "$cmd $dir" : '!\(.*\)'` tdir=`pwd` cd $cdir sh -c "$ex" cd $tdir echo '!' ;; *) echo "usage: [d][m dir][a dir][p][q][cntl-d][!cmd][*][new-line]" >&2;; esac trap 1 else break 3 fi done done fi done fi