X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f996b,1f69677d7ffe41f9 X-Google-Attributes: gidf996b,public X-Google-Thread: fbb9d,1f69677d7ffe41f9 X-Google-Attributes: gidfbb9d,public X-Google-ArrivalTime: 1994-10-13 06:21:25 PST Path: bga.com!news.sprintlink.net!sashimi.wwa.com!not-for-mail From: Tony Nugent Newsgroups: rec.arts.ascii,alt.ascii-art Subject: Info: Random .sig selection in mailers Date: 11 Oct 1994 23:18:48 -0500 Organization: Griffith University, Brisbane, Australia Lines: 307 Sender: boba@wwa.com Approved: boba@wwa.com Message-ID: <37fo38$quv@sashimi.wwa.com> References: <35r38l$3oc@dns1.NMSU.Edu> <35s74f$24t@gagme.wwa.com> <36ft2a$plq@sashimi.wwa.com> <3783k7$guu@gagme.wwa.com> Reply-To: T.Nugent@sct.gu.edu.au NNTP-Posting-Host: sashimi.wwa.com Xref: bga.com rec.arts.ascii:2072 alt.ascii-art:12934 H.Currie@mailbox.uq.oz.au (Hamish Currie) writes: >Alaska (alaska@gate.net) wrote: >: Alaska (alaska@gate.net) wrote: >:: Hamish Currie (H.Currie@mailbox.uq.oz.au) wrote: >::: Does anybody out there know of a mailer that will put in a .sig >::: at random ? >: (now if only more people could ask me questions that they already >: know the answer to ;) >What is the square root of twenty three ?? :) >Well I have not found any realy great ideas for this problem, I have had a >few solutions, At the moment I am choosing the .sig manually (^R to AARGH! I've posted a script to do this _three_ times now, and it still hasn't appeared here! :-( >attach a text file in the pine mailer) I had a script changing the .sig pine... hmmm, don't know if this Bourne script can be tweaked to work with pine, but it sure works well with nn (and mailx if you use that as a mailer). >one session of pine, and it was just not good enough. I am going to try >having a backgroung process changing the .sig every minute or so, But I >will have to see how it goes in terms of slowing down the computer. There was a c program recently posted to alt.sources that did that sort of this, but this script will randomly pick sigs when you want them. Not so long ago I posted this to the figlet list... 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 '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=//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 //injector -N -h X# set mailer //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 /_/\_\/_/\ \/_/\_\/_/ \_.--._/ tnugent@gucis.cit.gu.edu.au \_\/_/\_\/ \/_/\_\ v T.Nugent@sct.gu.edu.au /_/\_\/ \/_/ \_\/