Article View: news.software.readers
Article #6876TRN: Different sigs for different newsgroups.
From: Steven King
Date: Thu, 09 Dec 1993 13:35
Date: Thu, 09 Dec 1993 13:35
98 lines
4629 bytes
4629 bytes
newlight@comtch.iea.com (New Light Industries LTD) writes:
>Emily M. Breed (emilyb@netcom.com) wrote:
>: Does this work with trn? If it does, what's the init file to edit? I
>: checked, but didn't see any file called "init". (Well, this is
>
>The correct file to edit is _probably_ called trnrc. If you have a trn
>directory, it will probably be in that.
Well, first off, trn doesn't work the same way as nn. So the little
trick described a few messages back won't really work with trn. Trn
does have an init file, usually called ".trninit" or sometimes ".rninit"
(a hold over from the days of 'rn'). Actually the init file can be
called "Joes_Bar_And_Grill" if you like, so long as you point the
TRNINIT environment variable to it. Read the man page for more info.
So, how to get a different signature with every newsgroup? Here's a
little script I whipped up a while back. Works great for me. I ought
to send it to Wayne Davison to see he'll include it in future versions
of trn. There's probably a fancy macro string you can use instead, but
I find trn's macros only slightly less cryptic than the Dead Sea
Scrolls.
Documentation is in the header block, and the whole thing's pretty
self-obvious if you know perl. Looking it over I can see a couple
places where it can be tuned up a bit. I coded this a couple years ago
and I know much more about perl now. But hey, it works!
---=== Cut Here ===--- ---=== Cut Here ===---
#! /usr/bin/perl
#
# Steven King, 18 Dec 91
# veck@pshrink.chi.il.us
#
# Synopsis: Psig newsgroup [Pnews-parms]
# (Though this should only be called from a newsreader...)
#
# Selects a signature based on the current newsgroup. Psig will
# read the News directory tree in the user's home directory
# ($HOME/News/...) to find a file called "signature" in the
# current newsgroup. If that file doesn't exist, the directory
# tree will be followed backwards through the hierarchy looking for
# a signature. If none are found a random signature will be picked
# out of $sigdir
#
# When a signature is found it is copied to $HOME/.signature for
# inclusion in the article by inews. Pnews is then called to
# create and post the article.
#
# The $sigdir variable can be pointed to any directory. That
# directory should contain ONLY files you want to use as .signatures,
# and nothing else. Any file in $sigdir is fair game for inclusion.
#
# To get this to work from (t)rn, set the NEWSPOSTER environment
# variable to "Psig %C -h %h".
$home = $ENV{'HOME'};
$sigdir = "$home/.sigs";
@group = ("News",split(/\./,shift(@ARGV)));
$count = @group;
$found = 0;
while (@group) {
$gname = join('/',@group);
if (-f "$home/$gname/signature") {
print "(Using signature from $home/$gname)\n";
system("cp $home/$gname/signature $home/.signature");
$found = 1;
@group = ("dummy");
}
pop(@group);
}
if (! $found) {
opendir(SIGS,$sigdir);
@siglist = grep(!/^\./,readdir(SIGS));
closedir(SIGS);
$seed = time % ($$ * $$); # Seems to provide a good seed.
srand($seed);
$chosen = int((rand() * @siglist));
print "(Using random signature)\n";
system("cp $sigdir/@siglist[$chosen] $home/.signature");
}
if ($ENV{'DOTDIR'} && ($ENV{'DOTDIR'} ne $home)) {
system("cp $home/.signature $ENV{'DOTDIR'}/.signature");
}
system("cat $home/.signature");
system("Pnews @ARGV");
---=== Cut Here ===--- ---=== Cut Here ===---
--
----------------------------------------<Steven King, veck@pshrink.chi.il.us>--
You don't know how much you don't know until you know a lot.
(Nick Holland)
Technical Details
Message-ID:
<1993Dec9.133520.6623@pshrink.chi.il.us>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!gmd.de!xlink.net!zib-berlin.de!zrz.TU-Berlin.DE!math.fu-berlin.de!nigel.msen.com!usenet.ins.cwru.edu!eff!news.kei.com!ddsw1!pshrink!veckReferences:
<2dieo2$q4s@salmon.maths.tcd.ie> <2dm39j$omq@news.u.washington.edu> <emilybCHoMp7.53y@netcom.com> <1993Dec8.133839.6403@comtch.iea.com>Show Full Headers
Complete Article Headers
Message-ID: <1993Dec9.133520.6623@pshrink.chi.il.us> Subject: TRN: Different sigs for different newsgroups. Date: Thu, 9 Dec 1993 13:35:20 GMT From: veck@pshrink.chi.il.us (Steven King) References: <2dieo2$q4s@salmon.maths.tcd.ie> <2dm39j$omq@news.u.washington.edu> <emilybCHoMp7.53y@netcom.com> <1993Dec8.133839.6403@comtch.iea.com> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!gmd.de!xlink.net!zib-berlin.de!zrz.TU-Berlin.DE!math.fu-berlin.de!nigel.msen.com!usenet.ins.cwru.edu!eff!news.kei.com!ddsw1!pshrink!veck Newsgroups: news.newusers.questions,news.software.readers Organization: PShrink Wrap BBS, +1 708 487 9727 Reply-To: veck@pshrink.chi.il.us Lines: 98