home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 7.ddi / usr / bin / uulog < prev   
Encoding:
Text File  |  1990-12-08  |  1.6 KB  |  125 lines

  1. #!/usr/bin/sh
  2. #ident    "@(#)/usr/bin/uulog.sl 1.1 4.0 12/08/90 22892 AT&T-USL"
  3.  
  4. export IFS PATH
  5. IFS="     
  6. "
  7. PATH="/usr/bin"
  8.  
  9. #
  10. # usage:
  11. #     uulog
  12. # or    uulog foo
  13. # or    uulog -sfoo
  14. # or    uulog -s foo
  15. # or    uulog -ffoo
  16. # or    uulog -f foo
  17. #
  18. #    -x means check the execute file
  19. #    -nnn where 'nnn' is a number will do tail -nnn
  20. #
  21. LOGDIR=/var/uucp/.Log
  22. type=uucico
  23. fflag=""
  24. sys=""
  25. n=""
  26.  
  27. cd $LOGDIR
  28.  
  29. while [ $# -gt 0 ]
  30. do
  31.     case $1 in
  32.     -x)    type=uuxqt
  33.         shift
  34.         ;;
  35.  
  36.     -[0-9]*)n=`echo $1|cut -c2-`
  37.         shift
  38.         ;;
  39.  
  40.     -f)    fflag=1
  41.         shift
  42.         if [ $# -eq 0 ]
  43.         then
  44.             echo "uulog: system name must follow -f flag" 1>&2
  45.             exit 1
  46.         else
  47.             case "$1" in
  48.             -*)
  49.                 echo "uulog: system name must follow -f flag" 1>&2
  50.                 exit 1
  51.                 ;;
  52.             esac
  53.         fi
  54.         ;;
  55.  
  56.     -f*)    x=`echo $1|cut -c3-`
  57.         shift
  58.         set - $x $*
  59.         fflag=1
  60.         ;;
  61.  
  62.     -s)    shift
  63.         if [ $# -eq 0 ]
  64.         then
  65.             echo "uulog: system name must follow -s flag" 1>&2
  66.             exit 1
  67.         else
  68.             case "$1" in
  69.             -*)
  70.                 echo "uulog: system name must follow -s flag" 1>&2
  71.                 exit 1
  72.                 ;;
  73.             esac
  74.         fi
  75.         ;;
  76.  
  77.     -s*)    x=`echo $1|cut -c3-`
  78.         shift
  79.         set - $x $*
  80.         ;;
  81.  
  82.     -*)    echo "Invalid flag $1" 1>&2
  83.         exit 1
  84.         ;;
  85.  
  86.     *)    sys="$sys $1"
  87.         shift
  88.         ;;
  89.  
  90.     esac
  91. done
  92.  
  93. set - $sys
  94. if [ x$fflag = x ]; then
  95.     if [ $# = 0 ]; then
  96.         set - `/usr/bin/ls $type`
  97.     fi
  98.     for i in $*
  99.     do
  100.         if [ -f $type/$i ]
  101.         then
  102.             if [ x$n = x ]; then
  103.                 cat $type/$i
  104.             else
  105.                 tail -$n $type/$i
  106.             fi
  107.         else
  108.             echo "uulog: no log file available for system $i"
  109.             exit 1
  110.         fi
  111.     done
  112. else
  113.     if [ $# != 1 ]; then
  114.         echo "uulog: only one system allowed with -f" 1>&2
  115.         exit 2
  116.     fi
  117.     if [ -f $type/$1 ]
  118.     then
  119.         exec tail -${n}f $type/$1
  120.     else
  121.         echo "uulog: no log file available for system $1"
  122.         exit 1
  123.     fi
  124. fi
  125.