home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / base / root.15 / usr / bin / uuto / uuto~
Text File  |  1998-08-19  |  3KB  |  129 lines

  1. #!/usr/bin/sh
  2. #ident    "@(#)uuto    1.2"
  3. #ident "$Header: uuto 1.1 91/02/28 $"
  4.  
  5. uuto () {
  6. f=""
  7. d=""
  8. error="0"
  9. label="UX:uuto"
  10. cat="uxbnu"
  11. #    get file names
  12. #    files must be readable,
  13. #    directories must be readable/searchable
  14. #    otherwise increment error count and skip it.
  15. while test $#  -ge 1
  16. do
  17.     if test -d "$1" -a {"$1" = "." -o "$1" = ".."}
  18.         then shift; continue
  19.     elif test -r "$1" -a -f "$1"
  20.         then f="$f $1"
  21.     elif test -r "$1" -a -x "$1" -a -d "$1"
  22.         then d="$d $1"
  23.     else error=`expr 0$error + 1`
  24.         if test -f "$1"
  25.             then
  26.             pfmt -l UX:uuto -s error -g uxbnu:20 "<%s%s>: cannot read file\n" $UUP $1
  27.         elif test -d "$1"
  28.             then
  29.             pfmt -l UX:uuto -s error -g uxbnu:21 "<%s%s>: directory not readable/searchable\n" $UUP $1
  30.         else
  31.             pfmt -l UX:uuto -s error -g uxbnu:22 "<%s%s>: file/directory not found\n" $UUP $1
  32.         fi
  33.     fi
  34.     shift
  35. done
  36. if test -n "$d" -a -n "$user"
  37. then
  38.     for i in $d
  39.     do
  40.         ( cd $i; UUP="$UUP$i/"
  41.         uuto * $1)
  42.         error=`expr 0$error + 0$?`
  43.     done
  44. fi
  45.  
  46. if test -n "$f" -a -n "$user"
  47. then
  48.     uucp $a $f $remote!~/receive/$user/$mysys/$UUP
  49.  
  50.     if test "$?" != "0"
  51.     then
  52.         error=`expr 0$error + 01`
  53.     fi
  54. fi
  55.  
  56. return $error
  57. }
  58.  
  59. # main uuto shell
  60.  
  61. export IFS PATH
  62. IFS="     
  63. "
  64. PATH="/usr/bin"
  65.  
  66. a=""
  67. temp=""
  68. sub=""
  69. mysys=`uuname -l`
  70. mesg="Usage: %s [-m -p] files remote!user\n"
  71. label="UX:uuto"
  72. cat="uxbnu"
  73. sigmsg="received signal %s\\n"
  74. if test  $# -lt 1
  75.     then
  76.         pfmt -l $label -s action -g ${cat}:23 "$mesg" $0
  77.         exit 26
  78. fi
  79. trap "pfmt -l $label -s action -g ${cat}:26 \"$sigmsg\" '<1>'; exit 29" 1
  80. trap "pfmt -l $label -s action -g ${cat}:26 \"$sigmsg\" '<2>'; exit 29" 2
  81. trap "pfmt -l $label -s action -g ${cat}:26 \"$sigmsg\" '<3>'; exit 29" 3
  82. trap "pfmt -l $label -s action -g ${cat}:26 \"$sigmsg\" '<13>'; exit 29" 13
  83. trap "pfmt -l $label -s action -g ${cat}:26 \"$sigmsg\" '<15>'; exit 29" 15
  84. copy=0
  85. #    get options
  86. while true
  87. do
  88.     case $1 in
  89.      -m)    a="$a $1" sub="$sub -m" ;;
  90.      -p)    a="$a -C" sub="$sub -p" copy=1 ;;
  91.      -w)    a="$a -w";;
  92.      -*)    pfmt -l $label -s action -g ${cat}:23 "$mesg" $0; exit 26;;
  93.      *)    break ;;
  94.     esac
  95.     shift
  96. done
  97. #    be sure have both files and destination
  98. if test $# -eq 1
  99. then
  100.     pfmt -l $label -s action -g ${cat}:23 "$mesg" $0
  101.     exit 26
  102. fi
  103. #    skip file names to get to destination
  104. while test $#  -gt 1
  105. do
  106.     temp="$temp $1"
  107.     shift
  108. done
  109. #    the recipient arg: remote!user
  110. #    remote may be omitted (default is this machine)
  111. #    must have at least !user
  112. remote=`expr $1 : '\(.*\)!'`
  113. user=`expr $1 : '.*!\(.*\)'`
  114. if test -z "$user"
  115. then
  116.     pfmt -l $label -s error -g ${cat}:24 "incomplete destination -- must specify user\n"
  117.     exit 27
  118. fi
  119. a="$a -d -n$user"
  120.  
  121. UUP=""
  122. uuto $temp
  123.  
  124. if test "$error" != "0"
  125. then
  126.     pfmt -l $label -s error -g ${cat}:25 "failed with <%s> error(s)" $error
  127.     exit 28
  128. fi
  129.