Article View: news.software.nntp
Article #19184Re: [Q] a channel goes berserk
From: Joe Greco
Date: Fri, 11 Jul 1997 00:00
Date: Fri, 11 Jul 1997 00:00
71 lines
3235 bytes
3235 bytes
In news.software.nntp article <5q4vup$ag$1@beatles.cselt.it>, mau@beatles.cselt.it (Maurizio Codogno) wrote:
:I am playing with my newsfeed to create a cancelbot for binaries in it.
:hierarchy (yes, I know that there are many, but I want to learn how things
:work!)
:
:I have created a channel in my newsfeeds file:
:
:newsbot!\
: :!it.binari.*\
: :Tc,Ap,>9000,WbnmN\
: :/home/mau/coord/newsbot.sh
:
:where newsbot.sh is a bash script which basically loops forever:
:
:while [ x = x ] ; do
: read SIZE FILE MSGID GRUPPI && {
: [...]
: }
:done
:
:It works, but every time I reload newsfeeds the process is not killed, and
:it gets all of my CPU (fortunately I have two of them!). What should I do?
:Switch to a program, instead of a channel? Add some check in order to
:properly shut down the program?
:
:TIA, .mau.
No. A program feed spawns a program for EACH ARTICLE. Probably not
what you want unless you have a really hot box. Certainly not something
to do with a shell script.
What you want is to rewrite your program in C. :-) But since it's easy
to experiment in shell script, here's what is wrong: you are not ever
checking for end of file. Try something like this:
#! /bin/sh -
PATH=/bin:/usr/bin:/usr/local/bin; export PATH
while read size file msgid group; do
echo "${size}" "${file}" "${msgid}" "${group}" >> /tmp/log
done
Note that you need to be VERY VERY careful with variable expansions,
particularly the groups and message-ID, because these are essentially
user-supplied data (think about the ramifications of "<" and ">", or
a dollar sign in the msgid string). Using the "${variable}" notation
is reasonably safe, make sure you use double quotes.
I wrote an entire cancelbot and other tools in shell script. It's not
pretty, but it keeps my local hierarchy clean as a whistle. (No, don't
ask, it is not for public distribution.)
When working with cancelbots, be VERY, VERY careful. There is a lot of
room for pain and anguish should you screw up. If you're only interested
in cleaning up things locally, do NOT issue cancel messages. Just remove
the articles (or issue a ctlinnd command to INN to cancel the article).
Also, I recommend that if you are interested in only looking at the it.*
hierarchy, you SPECIFY that in your newsfeeds file. And you should
explicitly check for it in your code, too. That way, a mistake in one
place can not result in you inadvertently trying to cancel all of
alt.binaries.*.
It never hurts to check an extra time to make sure you're doing only
what you think you are.
... JG
Technical Details
Message-ID:
<5q5kcl$eme$1@earth.execpc.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mailReferences:
<5q4vup$ag$1@beatles.cselt.it>Show Full Headers
Complete Article Headers
Message-ID: <5q5kcl$eme$1@earth.execpc.com> Subject: Re: [Q] a channel goes berserk Date: Fri, 11 Jul 1997 00:00:00 +0000 From: jgreco@ns.sol.net (Joe Greco) References: <5q4vup$ag$1@beatles.cselt.it> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail X-Deja-AN: 256211730 Distribution: inet Sender: jgreco@earth.execpc.com Organization: sol.net Network Services - Milwaukee, WI Newsgroups: news.software.nntp