#!/usr/bin/perl # # news_post: Automatically Post the "input file" to the newsgroups # Requires that you can normally post a news article manually... # # # Check for: # /etc/NNTP_SERVER # -- or -- # bash: export NNTPSERVER=News.SomeDomain.com # # # # 12-Jan-97 amo Date-of-Birth # # # local ( $NM ) = "news_post"; # script name local ( $TMP ) = "/tmp/news_post.$$"; # local ( $FIL ) = "$ARGV[0]"; # File_to_post_to_NewsGroup"; # # Some News Header defaults # # newsfeed.pnl.gov does NOT have these test groups #RP="ba.test alt.test misc.test" # local ( @GRP ) = ( "mit.test", "scruz.test" ); # local ( $ELM ) = "elm"; local ( $NEWS ) = "inews -h"; local ( $DOM ) = "linux-consulting.com"; local ( $SUB ) = "Testing news posting"; local ( $COM ) = "Ring, Inc"; local ( $Who ) = "alvin"; local ( $Email ) = "$Who\@$DOM"; # local ( $id ) = 0; local ( $grp ) = ""; # ----------------------------------------- # # Check if we have at least the filename # &usage if ( $#ARGV < 0 ); &error ( "No such file=$FIL.." ) if ( ! -f $FIL ); # ------------------------------------------------------ # # Usage # sub usage { print "\n"; print "Usage: news_post [options] \n"; print "\n"; exit 1; } # # Error # sub error { local ( $msg ) = @_; # printf "$NM: ERROR: $msg\n"; print "\n"; exit 1; } # ---------------------------------------------- # # Prepare the File to be posted to the newsgroup # sub news_post { local ( $grp ) = @_; # # Check the files # open ( FHO, "> $TMP" ) || die "$NM: Could not open $TMP for write\n"; open ( FHI, "< $FIL" ) || die "$NM: Could not open $FIL for posting into newsgroups\n"; # # Prepare the News headers # ------------------------ # printf FHO "Newsgroups: $grp\n"; printf FHO "From: $Email\n"; printf FHO "Subject: $SUB\n"; printf FHO "Organization: $COM\n"; printf FHO "Reply-To: $Email\n"; # printf FHO "\n"; # # Now echo/concatenate the data file to post to the newsgroups # while () { printf FHO "$_"; } # File to post # close ( FHO ); # all done creating the file to post close ( FHI ); # --------------------------------------------------- # Post it and send an email copy too ( send to me ) # --------------------------------------------------- # system ( "$NEWS < $TMP" ); # # Do I need to modify the (news) headers before sending this email ?? # system ( "$ELM -s \"Copy of news posting to $grp\" alvin < $TMP > /dev/null" ); # } # news_post # ---------------------------------------------- # # Cycle thru each Newsgroup and Post the Article # # while ( $id <= $#GRP ) { # $grp = @GRP[$id]; print "$NM: Posting to $grp\n"; # some feedback # &news_post ( $grp ); # $id++; # } # cycle thru each newsgroup # ------------------------------------------------- # # Clean up and exit # unlink $TMP; printf "\n"; exit 0; # # end of script