home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume1 / 8706 / 24 / inews.sh
Linux/UNIX/POSIX Shell Script  |  1993-09-02  |  2KB  |  68 lines

  1. #!/bin/sh
  2. # A common situation is for a machine to use NFS to mount /usr/spool/news
  3. # remotely from another machine. This lets you read news via rn,
  4. # but it does not let you post news, since you have no inews program for
  5. # Pnews to call.
  6. # This shell will let you post mail by sendmailing it to another machine.
  7. # It was written to run on Suns, but can probably be made to work on other machines.
  8. #
  9. # You will have to change the name "oopsvax" to the name of a machine you
  10. # can send mail to that has rnews. (We use shasta, but you shouldn't unless you
  11. # are at Stanford).
  12. #
  13. # You will need to create the file /usr/lib/news/counter
  14. # (or wherever you decide to put it) to count message numbers.
  15. # It should start out containing the number "1".
  16. #
  17. # A copy of your article will be left in your home directory, called "article".
  18. #
  19. # By Joe Dellinger
  20. # further hacking by Conor Rafferty
  21. #
  22.  
  23. #initialization
  24. counter=/usr/lib/news/counter
  25. userart=$HOME/article
  26. oopsvax=???????
  27. itmp=/tmp/itmp$$
  28. trap "rm -f /tmp/itmp*" 0 1 2 3 13 15
  29.  
  30. #host and user name. Try the password file, then the yellow pages muck.
  31. if test "$hostname" = "" ; then hostname=`hostname`; fi
  32. passline=`grep :$USER: /etc/passwd` ||
  33. passline=`ypmatch $USER passwd.byname` ||
  34. passline=dummy:dummy:dummy:dummy:$USER
  35. export passline
  36. fullname="`(IFS=:;set $passline; echo $5)`"
  37.  
  38. # Grab stdin
  39. cat > $userart
  40. if \[ -f $HOME/.signature \] ; then
  41. cat $HOME/.signature >> $userart
  42. fi
  43.  
  44. # Increment the message ID number for this system
  45. number=`cat $counter`
  46. number=`expr $number + 1`
  47. echo $number > $counter
  48.  
  49. # simulate inews header
  50. # remote rnews does a lot of the work itself (date reformat, Lines)
  51. echo "Subject: network news posting"            > $itmp
  52. echo "To: rnews@$oopsvax"                      >> $itmp
  53. echo ""                                        >> $itmp
  54. echo "NPath: $hostname!$USER"                  >> $itmp  #path back to you
  55. echo "NFrom: $USER@$hostname.UUCP ($fullname)" >> $itmp  #want the full name
  56. echo "NMessage-ID: <$number@$hostname.UUCP>"   >> $itmp  #rnews junks it otherwise
  57. echo "NDate: `date`"                           >> $itmp  #ditto
  58.  
  59. #stuff in the user input
  60. sed 's/^/N/' $userart                          >> $itmp
  61.  
  62.  
  63. # Send it off to $oopsvax to be posted
  64. /usr/lib/sendmail -i rnews@$oopsvax < $itmp
  65.  
  66. # That's it. The article is left in your home directory.
  67.