Info: Script for random .sig selection in mail and news
From Tony Nugent <T.N...@sct.gu.edu.au>
· rec.arts.ascii
· 6 Oct 1994 02:22 · View full thread
· report
ala...@gate.net (Alaska) writes: >Hamish Currie (H.C...@mailbox.uq.oz.au) wrote: >: Does anybody out there know of a mailer that will put in a .sig >: at random ? (if not I suppose I can use tin to do my mailing) >: thanks > A mailer? you mean like a mail reader like elm? I know elm has no >problem with putting sigs at the bottom of letters. I don't know about >mail or mailx. I also know that Pine can also put sigs at the bottom >of letters (change the pinerc (?) and elmrc respectivly.) If your >talking about something else I don't have a clue (I know people are >already saying that bout me ;). Sorry that I missed the original post by Hamish. I recently posted this script in alt.sources and sent it to the figlet list. It seems that it would be appropriate to post it here too... This Bourne shell script "injects" sigs and "fortune cookies" into your email and usenet posts on a (pseudo) random basis. 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. I have thought of some improvements, which I'll eventually get around to doing. 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.N...@sct.gu.edu.au tnu...@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.N...@sct.gu.edu.au tnu...@gucis.cit.gu.edu.au X# Based on a set of shell scripts originally by X# Dave Conners, dco...@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 /_/\_\/_/\ \/_/\_\/_/ \_.--._/ tnu...@gucis.cit.gu.edu.au \_\/_/\_\/ \/_/\_\ v T.N...@sct.gu.edu.au /_/\_\/ \/_/ \_\/
Original message headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f996b,ac1472087b8efcb,start X-Google-Attributes: gidf996b,public X-Google-Thread: fbb9d,ac1472087b8efcb,start X-Google-Attributes: gidfbb9d,public X-Google-ArrivalTime: 1994-10-06 00:05:38 PST Path: bga.com!news.sprintlink.net!sashimi.wwa.com!not-for-mail From: Tony Nugent <T.N...@sct.gu.edu.au> Newsgroups: rec.arts.ascii,alt.ascii-art Subject: Info: Script for random .sig selection in mail and news Date: 5 Oct 1994 21:22:45 -0500 Organization: Griffith University, Brisbane, Australia Lines: 295 Sender: bob...@wwa.com Approved: bob...@wwa.com Message-ID: <36vn1l$kb...@sashimi.wwa.com> Reply-To: T.N...@sct.gu.edu.au NNTP-Posting-Host: sashimi.wwa.com Xref: bga.com rec.arts.ascii:1941 alt.ascii-art:12683
Related ASCII art in the Gallery
Explore these categories from our collection of 11,000+ artworks:
Make your own ASCII art
Turn images, text or 3D into ASCII, or draw your own – right in your browser.
About this message.
This message was posted publicly to the newsgroup
rec.arts.ascii
in 1994 and is mirrored here unchanged as part of the Historic Archives – only email addresses are masked.
The artwork and text belong to their original authors: if you copy a piece, keep the artist's initials or signature intact and credit them where you can.
Are you the author? Contact us to get your posts attributed, connected to your artist profile, or removed.
Report this message
Help us keep the archive clean and accurate. Reports are reviewed by a person – nothing is changed automatically.