home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / unix / volume01 / uuque < prev    next >
Encoding:
Internet Message Format  |  1988-09-11  |  4.2 KB

  1. From: amd!turtlevax!ken (Ken Turkowski)
  2. Subject: uuque - a uuwizard's utility for uucp queue snooping
  3. Newsgroups: mod.sources
  4.  
  5. This is a shell script that I've put together to check out the sorts of
  6. things that have been queued up in the uucp queues.  I can only
  7. guarantee it for rnews, rmail, and uucp copies, but with a little
  8. hacking it could work for batched news, etc.  Any enhancements would be
  9. welcome.
  10. --
  11. Ken Turkowski @ CADLINC, Palo Alto, CA
  12. UUCP: {amd,decwrl,flairvax,nsc}!turtlevax!ken
  13. ARPA: turtlevax!ken@DECWRL.ARPA
  14.  
  15. -----------------------------------------------------------------
  16. echo x - uuque
  17. cat >uuque <<'!Funky!Stuff!'
  18. #! /bin/sh
  19. # The user must have access to the /usr/spool/uucp/* directories and files.
  20. # This can be easily done by making certain users members of the daemon
  21. # and/or uucp groups.
  22. # uusnap
  23. cd /usr/spool/uucp
  24. LUUNAME=`uuname -l`
  25. verbose=false
  26. system='*'
  27.  
  28. # Process flags
  29. for arg
  30. do
  31.     case $arg in
  32.     -v)
  33.         verbose=true
  34.         ;;
  35.     -s)
  36.         echo Syntax: '-sSYSTEM'
  37.         ;;
  38.     -s*)
  39.         arg=`expr $arg : '-s\(.*\)'`
  40.         system=`expr $arg : '\(.......\)'` || system=$arg
  41.         ;;
  42.     *)
  43.         echo Unknown flag: $arg
  44.         ;;
  45.     esac
  46. done
  47.  
  48. # Check for outgoing work
  49. for cmdfile in C./*
  50. do
  51.     test -f $cmdfile || continue
  52.     othersys=`expr $cmdfile : 'C./C.\(.*\).....'`
  53.     case $othersys in
  54.     $system)
  55.         ;;
  56.     *)
  57.         continue
  58.         ;;
  59.     esac
  60.     cmd=
  61.     xfile=
  62.     cat $cmdfile | {
  63.     while read cmd arg1 arg2 arg3 extra
  64.     do
  65.         case $cmd in
  66.         S)                # uucp send
  67.             case $arg1 in
  68.             D.${LUUNAME}X????)    # Remote execute file
  69.                 xfile=$arg1
  70.                 ;;
  71.             D.${LUUNAME}?????)    # Data file ref'd by xfile
  72.                 dfile=D.${LUUNAME}/$arg1
  73.                 ;;
  74.             *)        # Just a uucp -- no intertpretation
  75.                 echo `ls -l $arg1 | awk '{print $4}'`\     uucp $arg1 $othersys!$arg2 \($arg3\)
  76.                 ;;
  77.             esac
  78.             ;;
  79.         R)        # uucp receive
  80.             echo '    ' uucp $othersys!$arg1 $arg2 \($arg3\)
  81.             ;;
  82.         *)  echo Bad cmd in $cmdfile: $cmd $arg1 $arg2 $arg3 $extra
  83.             continue ;;
  84.         esac
  85.     done
  86.     case $xfile in
  87.         "")            # uucp transfer
  88.         continue
  89.         ;;
  90.     esac
  91.     cat D.${LUUNAME}X/$xfile | {    # complex transfer -- interpret xfile
  92.         while read xcmd arg1 arg2 extra
  93.         do
  94.         case $xcmd in
  95.             U)
  96.             from=$arg2!$arg1
  97.             ;;
  98.             F)
  99.             ;;
  100.             I)
  101.             ;;
  102.             Z)
  103.             ;;
  104.             C)
  105.             case $arg1 in
  106.                 rmail)
  107.                 from=`head -1 $dfile | ( read arg1 arg2 extra; echo $arg2 )`
  108.                 echo `ls -l $dfile | awk '{print $4}'`\     $arg1 $othersys!$arg2 \($from\)
  109.                 if $verbose
  110.                 then
  111.                     echo -n '     '
  112.                     grep '^Subject:' $dfile || echo ''
  113.                 fi
  114.                 ;;
  115.                 rnews)
  116.                 echo `ls -l $dfile | awk '{print $4}'`\     $arg1 $othersys  \($from\)
  117.                 if $verbose
  118.                 then
  119.                     echo -n '     '
  120.                     grep '^Newsgroups:' $dfile
  121.                     echo -n '     '
  122.                     grep '^Subject:' $dfile
  123.                 fi
  124.                 ;;
  125.                 *)
  126.                 echo `ls -l $dfile | awk '{print $4}'`\     $arg1 $arg2 $extra [$othersys $dfile] \($from\)
  127.                 ;;
  128.             esac
  129.             ;;
  130.             *)
  131.             echo Unknown xcmd in $xfile: $xcmd $arg1 $arg2
  132.             exit
  133.             ;;
  134.         esac
  135.         done
  136.     }
  137.     }
  138. done
  139.  
  140. # Check for incoming work
  141. for cmdfile in X./*
  142. do
  143.     test -f $cmdfile || continue
  144.     othersys=`expr $cmdfile : 'X./X.\(.*\).....'`
  145.     case $othersys in
  146.     $system)
  147.         ;;
  148.     *)
  149.         continue
  150.         ;;
  151.     esac
  152.     comment=
  153.     cat $cmdfile | {
  154.     while read cmd arg1 arg2 extra
  155.     do
  156.         case $cmd in
  157.         U)
  158.             from=$arg2!$arg1
  159.             ;;
  160.         Z)
  161.             ;;
  162.         I)
  163.             ;;
  164.         F)
  165.             if test -f D./$arg1
  166.             then
  167.             dfile=D./$arg1
  168.             elif test -f D.$LUUNAME/$arg1
  169.             then
  170.             dfile=D.$LUUNAME/$arg1
  171.             elif test -f XTMP/$arg2
  172.             then
  173.             dfile=XTMP/$arg2
  174.             comment="[EXECUTING]"
  175.             else
  176.             continue 2
  177.             fi
  178.             ;;
  179.         C)
  180.             xcmd=$arg1
  181.             xargs="$arg2 $extra"
  182.             case $arg1 in
  183.             rmail)
  184.                 from=$othersys!`head -1 $dfile | ( read arg1 arg2 extra; echo $arg2 )`
  185.                 echo `ls -l $dfile | awk '{print $4}'`\     $xcmd $xargs $comment \($from\)
  186.                 if $verbose
  187.                 then
  188.                 echo -n '     '
  189.                 grep '^Subject:' $dfile || echo ''
  190.                 fi
  191.                 ;;
  192.             *)
  193.                 echo `ls -l $dfile | awk '{print $4}'`\     $xcmd $xargs $comment \($from\)
  194.                 ;;
  195.             esac
  196.             ;;
  197.         *)  echo Bad cmd in $cmdfile: $cmd $arg1 $arg2 $extra
  198.             continue ;;
  199.         esac
  200.     done
  201.     }
  202. done
  203. !Funky!Stuff!
  204. chmod +x uuque
  205. echo uuque extracted successfully
  206. exit 0
  207.  
  208.  
  209.