🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nn
Article #6540

Re: .signature file aborts post ? (Random .sig injector script!!)

#6540
From: Tony Nugent
Date: Sun, 16 Oct 1994 06:26
296 lines
10958 bytes
awanm@news.gate.net (awanm@gate.net) writes:


>I can't post with my .signature file. I get a post aborted message, due 
>to .signature file being too long, when I try it. I don't think my 
>.signature file is too long. Following is a copy of my .signature file

>	Florida Internet Providers List
>	is available through :
>	ftp inca.gate.net/pub/users/awanm 
>	URL: http://www.gate.net/~awanm

That should be fine... 4 lines is a usual limit.

However, do you want to overcome this limit, use this script that
I've put together that will put random .sigs into your news (and
email), or you are at liberty to hack it so that it always
inserts the same sig...

BTW, I've since thought of some improvements to this, but I
haven't had the time to update it.  However, hack to your heart's
content!!  :-)   (but give credit where credit is due)

============8<----------cut---------------------------------

This little script here "injects" sigs and "fortune cookies"
into your email and usenet posts on a (pseudo) random basis.
This is pure Bourne shell script.

I've tested this quite extensively, but I CANNOT guarantee that
it will work perfectly for you.  Read the notes at the end of
this script about how to use it and how to set up mail/mailx and
nn to enable this.  Note that I have only ever used this with these
programs... I have no idea how they might work with other email
program and news readers like pine, rn, or tin.

Be sure to read this script throughly, making alterations where
necessary for your system / setup.  It should be fairly generic
as it is, once you have things set up for yourself.  Check also
your man pages for nn, mail, mailx and sendmail to make sure they
will behave as expected.  Experiment by emailing to yourself, and
posting in misc.test or alt.test.

It works for me.  Your mileage may vary.  If anyone picks up any
bugs or has suggestions for improvements, then please don't
hesitate to email me.

injector is shar'ed below.

Oh, one last thing.  I've included another little script that I
use to centre lines.  I use it in my injector script.  I'll put
this one here plain... if anyone can suggest how I can improve on
this one, I'm all ears!  (It uses nawk, but surely there's a
better way to do it:)  This script follows the shar script.

Enjoy!


#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  injector
# Wrapped by sctnugen@kraken on Wed Sep 28 15:03:17 1994
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'injector' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'injector'\"
else
echo shar: Extracting \"'injector'\" \(5478 characters\)
sed "s/^X//" >'injector' <<'END_OF_FILE'
X#!/bin/sh
X#
X#!/usr/bin/sh here on my Solaris 2.3 / SunOS 5.3
X#
X############
X# injector # Version 1.0
X############
X#
X######################################################################
X# Email and Usenet news random signature and fortune cookie injector #
X######################################################################
X#
X# Tony Nugent    September 1994
X# T.Nugent@sct.gu.edu.au tnugent@gucis.cit.gu.edu.au
X#
X# SEE USAGE NOTES AT THE END OF THIS SCRIPT
X#
X################################################################
X# Get rid of the tmp files if an error occurs
X#############################################
Xcleanup()
X{
X  rm -f $tmpmsg $tmpsig
X  exit 1
X}
Xtrap cleanup 1 2 3
X#
X# Set up the files and directories to use
X#########################################
X#
Xsigdir="$HOME/.sigs"
Xsigfiles=".sig."
Xtmpdir="/tmp"
Xmailhead="$sigdir/.head"
Xmailtail="$sigdir/.tail"
Xtmpmsg="$tmpdir/injector.$$"
Xtmpsig="$tmpdir/injector.sig.$$"
X#
X# Set programs to use
X#####################
X#
Xmailer="/usr/lib/sendmail"
Xif [ X$1 = X-N ]; then
X  mailer="/usr/local/bin/inews"
X  shift
Xfi
X#
X# Get random fortune cookie
X# (insert your fortune cookie program here)
X###########################################
X#
X  fortune="echo insert witty saying here"
X# fortune="$HOME/bin/goofey -f 3"
X#
X# Choose a random .sig file
X###########################
X#
X# Find the number of .sig.* files
Xnumsigs=`ls ${sigdir}/${sigfiles}* | wc -w`
X# Get a pseudo-random number (based on the current process number)
Xrseed=$$
X# Make this number 0 -> $numsigs
Xrnd=`expr $rseed % $numsigs`
X# Set the .sig file name
Xmailsig="${sigdir}/${sigfiles}${rnd}"
X#
X################################################################
X# Now down to work!
X###################
X#
X# Get the message from stdin and save it
X#
Xcat - > $tmpmsg
X#
X# Check for noquote in the last three lines
X#
Xif ( [ `tail -3 $tmpmsg | grep noquote | wc -l` -eq 1 ]); then
X  # Don't continue processing if it's there
X  # But get rid of the line with noquote in it
X  numl=`wc -l < $tmpmsg`
X  topl=`expr $numl - 3`
X  head -$topl $tmpmsg > $tmpsig
X  tail -3 $tmpmsg | grep -v noquote >> $tmpsig
X  cat $tmpsig | $mailer "$@"
X  #
Xelse
X  #
X  # add intro
X  if [ -r $mailhead ] ; then
X    cat $mailhead       >> $tmpmsg
X  fi
X  #
X  # add signature
X  cat $mailsig         > $tmpsig
X  #
X  # add fortune cookie (centred) for email only
X  if [ `basename $mailer` = sendmail ]; then
X    if [ "X$fortune" != X ]; then
X      $fortune | centre >> $tmpsig
X      # add tail line
X      if [ -r $mailtail ]; then
X        cat $mailtail >> $tmpsig
X      fi
X    fi
X  fi
X
X  # send it off
X  cat $tmpmsg $tmpsig  | $mailer "$@"
X
X  # let's have a peek at the sig and the cookie...
X  cat $tmpsig > /dev/tty
Xfi
Xrm $tmpsig
Xrm $tmpmsg
Xexit 0
X
X#####################################################################
X# Email and Usenet news random signature and fortune cookie injector.
X#####################################################################
X# Only tested with nn and mail/mailx.
X#
X# Tony Nugent    September 1994
X# T.Nugent@sct.gu.edu.au tnugent@gucis.cit.gu.edu.au
X# Based on a set of shell scripts originally by
X# Dave Conners, dconnors@gucis.cit.gu.edu.au
X# (But hacked almost beyond recognition now! :-)
X#
X################################################################
X#
X# WARNING!       USE AT YOUR OWN RISK !!!
X#
X# You are well advised to test this script before using it by
X# emailing to yourself and posting to misc.test or alt.test
X# (with "ignore no reply" as the subject, unless you like lots
X# of dead email :-).
X#
X# Read the man pages for nn, mail, mailx and sendmail
X# (and inews if it's there) before using this script.
X#
X################################################################
X#
X#           SETUP AND USAGE NOTES
X#
X# This file works by taking a message being piped to it from
X#   mailx and nn, WITH command-line parameters.
X#
X###############################
X#
X# To use this script with mail or mailx, point the
X#    sendmail variable in the ~/.mailrc file to it:
X#
X# sendmail=/<fullpath>/injector
X#
X###############################
X#
X# To use with nn, add the following to the ~/.nn/init file
X#    to point the inews and mailer variables to it:
X#
X# set inews /<fullpath>/injector -N -h
X# set mailer /<fullpath>/injector -t
X# set append-signature-mail false
X# set append-signature-post false
X#
X# The inews and mailer parameters may vary with your system's
X# setup, but to allow this script identify the _source_ of the
X# calling program, set the -N parameter with inews.
X#
X# If you have ~/.signature or ~/.Signature files, then delete them.
X#
X###############################
X#
X# Create a directory that contains all your .sig files.
X# I have used ~/.sigs here, but edit for your own tastes.
X#
X# Create a series of sequentially numbered .sig.* files, start at .sig.0
X# I have used .sig.0 .sig.1 .sig.2 etc; again edit as desired.
X# You can have as many as you like, but restrict them to only a few lines.
X#
X# Create two files called .head and .tail (in the ~/.sigs directory)
X# .head contains your usual "signoff" (eg, "Cheers \nTony")
X# .tail contains anything you want to finish off your sig, like
X#       a fancy one-liner or whatever.
X#
X# TO PREVENT THE INJECTION OF ANY .SIG:
X#  That is, to tell this script not to do its usual thing:
X#    - just add "noquote" to the end of your message!
X#    - be warned that any line of your message with "noquote"
X#      in the last few lines will be deleted from the message.
X#
X###############################
END_OF_FILE
if test 5478 -ne `wc -c <'injector'`; then
    echo shar: \"'injector'\" unpacked with wrong size!
fi
chmod +x 'injector'
# end of 'injector'
fi
echo shar: End of shell archive.
exit 0


====8<----cut-for-centre-----------------------------------
#!/bin/sh
#
#!/usr/bin/sh here on my Solaris 2.3 / SunOS 5.3
#
# centre all input text on an 80-column line
cat - | nawk '{ if ( length < 80 ) {          \
                  le = ( 80-length ) / 2 ;    \
                  for ( i=1 ; i<=le ; i++ ) { \
                    printf(" ") } ;           \
                } print $0                    \
              }'
====8<----cut-for-centre-----------------------------------

Cheers
Tony
     Tony Nugent  Griffith University, Brisbane, Queensland, Australia
          Email:  T.Nugent@sct.gu.edu.au  tnugent@gucis.cit.gu.edu.au
     _   _   _   _   _   _   _   _   _   _   _   _   _   _   _   _   _   _
   _/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \
  / \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
  \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
Technical Details
Message-ID: <37qh3b$bdk@griffin.itc.gu.edu.au>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.nn.mbox.zip!bga.com!news.sprintlink.net!redstone.interpath.net!ddsw1!news.kei.com!MathWorks.Com!usenet.eel.ufl.edu!usenet.cis.ufl.edu!caen!msuinfo!harbinger.cc.monash.edu.au!bunyip.cc.uq.oz.au!griffin.itc.gu.edu.au!news
References: <awanm.782023933@gate.net>

Show Full Headers
Complete Article Headers
Message-ID: <37qh3b$bdk@griffin.itc.gu.edu.au>
Subject: Re: .signature file aborts post ? (Random .sig injector script!!)
Date: Sun, 16 Oct 1994 06:26:51 +0000
From: Tony Nugent <T.Nugent@sct.gu.edu.au>
References: <awanm.782023933@gate.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.nn.mbox.zip!bga.com!news.sprintlink.net!redstone.interpath.net!ddsw1!news.kei.com!MathWorks.Com!usenet.eel.ufl.edu!usenet.cis.ufl.edu!caen!msuinfo!harbinger.cc.monash.edu.au!bunyip.cc.uq.oz.au!griffin.itc.gu.edu.au!news
Newsgroups: news.software.nn
Organization: Griffith University, Brisbane, Australia
Lines: 296
Reply-To: T.Nugent@sct.gu.edu.au
NNTP-Posting-Host: kraken.itc.gu.edu.au