home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff319.lzh / CNewsSrc / cnews.orig.lzh / relay / aux / newsreply < prev    next >
Text File  |  1989-06-27  |  1KB  |  58 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. art=/tmp/nc$$
  13. mroute=/tmp/ncm$$
  14.  
  15. cat >$art
  16.  
  17. if test -r $NEWSCTL/replyusepath
  18. then
  19.     sender="`grep '^Path:' $art | sed 's/^[^:]*://' `"
  20.     echo "$sender"
  21.     rm -f $art
  22.     exit 0
  23. fi
  24.  
  25. # pick out the appropriate header
  26. sender="` grep '^Reply-To:' $art `"
  27. case "$sender" in
  28. "")    sender="` grep '^From:' $art `" ;;
  29. esac
  30.  
  31. # strip header keyword, full name & duplicate lines, print result.
  32. # this copes with "address", "address (full name)" and "full name <address>".
  33. sender=` echo "$sender" | sed 's/^[^:]*:[     ]*//
  34. s/ (.*)//
  35. s/.*<\(.*\)>/\1/
  36. 1q' `
  37.  
  38. # B 2.11 mailpaths/"internet" hack
  39. cat $NEWSCTL/mailpaths |
  40.     while read ngpat route junk
  41.     do
  42.         case "$ngpat" in
  43.         internet)
  44.                 echo "$route" >$mroute
  45.                 break
  46.                 ;;
  47.         esac
  48.     done
  49. if test -s $mroute; then
  50.     sed "s/%s/`
  51.         echo $sender | sed 's/\(.*\)@\(.*\)/\2!\1/'
  52.         `/" <$mroute    # the real B 2.11 hack: u@d -> route!d!u
  53. else
  54.     echo $sender
  55. fi
  56.  
  57. rm -f $art $mroute
  58.