Thread View: news.software.nntp
5 messages
5 total messages
Started by Maurizio Codogno
Fri, 11 Jul 1997 00:00
[Q] a channel goes berserk
Author: Maurizio Codogno
Date: Fri, 11 Jul 1997 00:00
Date: Fri, 11 Jul 1997 00:00
28 lines
1227 bytes
1227 bytes
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.
Re: [Q] a channel goes berserk
Author: Maurizio Codogno
Date: Fri, 11 Jul 1997 00:00
Date: Fri, 11 Jul 1997 00:00
12 lines
874 bytes
874 bytes
Andrew Gierth <andrew@erlenstar.demon.co.uk> states: % Well, there's your problem; the script needs to die when it runs % out of input. Ah. This means that it is reopened every time an article arrives. Well, it was not intuitive for me :-) thanks, .mau.
Re: [Q] a channel goes berserk
Author: 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
Re: [Q] a channel goes berserk
Author: Andrew Gierth
Date: Fri, 11 Jul 1997 00:00
Date: Fri, 11 Jul 1997 00:00
25 lines
1167 bytes
1167 bytes
>>>>> "Maurizio" == Maurizio Codogno <mau@beatles.cselt.it> writes:
Maurizio> where newsbot.sh is a bash script which basically loops forever:
Well, there's your problem; the script needs to die when it runs
out of input.
Maurizio> while [ x = x ] ; do
Maurizio> read SIZE FILE MSGID GRUPPI && {
Maurizio> [...]
Maurizio> }
Maurizio> done
Try
while read SIZE FILE MSGID GRUPPI
do
...
done
--
Andrew.
Re: [Q] a channel goes berserk
Author: Andrew Gierth
Date: Fri, 11 Jul 1997 00:00
Date: Fri, 11 Jul 1997 00:00
20 lines
1335 bytes
1335 bytes
>>>>> "Maurizio" == Maurizio Codogno <mau@beatles.cselt.it> writes: Andrew Gierth <andrew@erlenstar.demon.co.uk> states: % Well, there's your problem; the script needs to die when it runs % out of input. Maurizio> Ah. This means that it is reopened every time an article arrives. Nononono. *Program* feeds are run once per article. *Channel* feeds are simply fed a line of input (or more if certain flags are used) every time an article arrives, and their input is closed when the channel is flushed. -- Andrew.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads