joe@hanauma.stanford.edu (Joe Dellinger) (11/26/87)
Here is a shell I put together a few months ago to allow me to post news from my Sun. I don't really have news at all on my machine. I just managed to find a remote site I can nfs the news stuff from, and installed "rn" to read it with. This shell version of "inews" is short, sweet, and works fine. People will need to slightly customize it for their site, but it is easily understandable I think. - Joe Dellinger, Stanford Exploration Project #!/bin/sh # A common situation is for a machine to use NFS to mount /usr/spool/news # remotely from another machine. This lets you read news via rn, # but it does not let you post news, since you have no inews program for # Pnews to call. # # This shell will let you post mail by sendmailing it to another machine. # It was written to run on Suns, but can probably be made to work on other machines. # # You will have to replace the name "oopsvax" with the name of a machine you # can send mail to that has rnews. (We use labrea, but you shouldn't unless you # are at Stanford). You will need to replace "mailhandler?" with the name of # the machine where you get mail (or use the commented out versions of the # lines if the machine you post from is also the machine you get your mail on). # # You will need to create the file /usr/lib/news/counter # (or wherever you decide to put it) to count message numbers. # It should start out containing the number "1". # # A copy of your article will be left in your home directory, called "article". # # You may want to change the return address, path, etc, for your site. # # By Joe Dellinger, Stanford Exploration Project, Stanford University, May 1987 # further hacking by Conor Rafferty # #initialization counter=/usr/lib/news/counter # file with article counter userart=$HOME/article oopsvax=labrea # machine that has the real inews mailhandlerl=arfsnargle.stanford.edu # long version of name mailhandlers=arfsnargle # short version of name itmp=/tmp/itmp$$ trap "rm -f /tmp/itmp*" 0 1 2 3 13 15 #host and user name. Try the password file, then the yellow pages muck. if test "$hostname" = "" ; then hostname=`hostname`; fi passline=`grep :$USER: /etc/passwd` || passline=`ypmatch $USER passwd.byname` || passline=dummy:dummy:dummy:dummy:$USER export passline fullname="`(IFS=:;set $passline; echo $5)`" # Grab stdin cat > $userart if \[ -f $HOME/.signature \] ; then cat $HOME/.signature >> $userart fi # Increment the message ID number for this system number=`cat $counter` number=`expr $number + 1` echo $number > $counter # simulate inews header # remote rnews does a lot of the work itself (date reformat, Lines) echo "Subject: network news posting" > $itmp echo "To: rnews@$oopsvax" >> $itmp echo "" >> $itmp echo "NPath: $mailhandlerl!$USER" >> $itmp #path back to you #echo "NPath: $hostname!$USER" >> $itmp #path back to you echo "NFrom: $USER@$mailhandlerl ($fullname)" >> $itmp #want the full name #echo "NFrom: $USER@$hostname.UUCP ($fullname)" >> $itmp #want the full name echo "NMessage-ID: <$number@$hostname.UUCP>" >> $itmp #rnews junks it otherwise echo "NDate: `date`" >> $itmp #ditto #stuff in the user input sed 's/^/N/' $userart >> $itmp # Send it off to $oopsvax to be posted /usr/lib/sendmail -i rnews%$oopsvax@$mailhandlers < $itmp #/usr/lib/sendmail -i rnews@$oopsvax < $itmp # That's it. The article is left in your home directory.