home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 400-499 / ff473.lzh / CNewsSrc / cnews_src.lzh / relay / aux / newsreply < prev    next >
Text File  |  1990-01-11  |  1KB  |  57 lines

  1. #! /bin/sh
  2. # newsreply - print return address from news article on stdin
  3. # This version assumes a domain mailer (user@host.domain works) or
  4. # "internet" in mailpaths file, unless $NEWSCTL/replyusepath exists.
  5.  
  6. # =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  7. . ${NEWSCONFIG-/usr/lib/news/bin/config}
  8. export NEWSCTL NEWSBIN NEWSARTS
  9. PATH=$NEWSCTL/bin:$NEWSBIN:$NEWSPATH ; export PATH
  10. umask $NEWSUMASK
  11.  
  12. hdr=/tmp/nc$$
  13. mroute=/tmp/ncm$$
  14.  
  15. canonhdr >$hdr
  16.  
  17. if test -r $NEWSCTL/replyusepath
  18. then
  19.     grep '^Path:' $hdr | sed 's/^[^:]*:[     ]*//'
  20.     rm -f $hdr
  21.     exit 0
  22. fi
  23.  
  24. # pick out the appropriate header
  25. sender="` grep '^Reply-To:' $hdr `"
  26. case "$sender" in
  27. "")    sender="` grep '^From:' $hdr `" ;;
  28. esac
  29.  
  30. # strip header keyword, full name & duplicate lines, print result.
  31. # this copes with "address", "address (full name)" and "full name <address>".
  32. sender=` echo "$sender" | sed 's/^[^:]*:[     ]*//
  33. s/ (.*)//
  34. s/.*<\(.*\)>/\1/
  35. 1q' `
  36.  
  37. # B 2.11 mailpaths/"internet" hack
  38. cat $NEWSCTL/mailpaths |
  39.     while read ngpat route junk
  40.     do
  41.         case "$ngpat" in
  42.         internet)
  43.                 echo "$route" >$mroute
  44.                 break
  45.                 ;;
  46.         esac
  47.     done
  48. if test -s $mroute; then
  49.     sed "s/%s/`
  50.         echo $sender | sed 's/\(.*\)@\(.*\)/\2!\1/'
  51.         `/" <$mroute    # the real B 2.11 hack: u@d -> route!d!u
  52. else
  53.     echo $sender
  54. fi
  55.  
  56. rm -f $hdr $mroute
  57.