Thread View: news.software.nntp
1 messages
1 total messages
Started by kjell
Mon, 14 Apr 2008 18:24
controlcancel.pl
Author: kjell
Date: Mon, 14 Apr 2008 18:24
Date: Mon, 14 Apr 2008 18:24
133 lines
4267 bytes
4267 bytes
I'm trying to run this script on my INN server
http://www.df.lth.se/~mikaelb/control.cancel/controlcancel.txt
I get this error "NNTPERROR: 502 Permission denied"
after this line "my ($first, $last) = $c->group("control.cancel");"
I get this error "NNTPERROR: 412 Not in a newsgroup"
after this line "for(; $last >= $first; --$last) {
my $head = join('', $c->head($last));
The script:
#!/usr/bin/perl
#
# controlcancel.pl v0.0.0
# Author: Mikael O. Bonnier, mikaelb@df.lth.se,
http://www.df.lth.se/~mikaelb/
# Copyright (C) 2007 by Mikael O. Bonnier, Lund, Sweden.
# License: GNU GPL v3 or later, http://www.gnu.org/licenses/gpl-3.0.txt
# Commercial licenses are available.
#
# Purpose: To store control.cancel messages for a group on an
NNTP-server
# in textfiles.
# Motive: Sometimes messages are canceled against the will of the
sender.
# In order to investigate this one needs the control.cancel message
but they
# normally can be difficult to find.
# Example: http://www.df.lth.se/~mikaelb/control.cancel/
# Installation: Adjust cfg-block in this file. Create an empty file
<group>_0000.txt in
# the <dir>. Run using crontab each night, e.g.
# 15 4 * * * cd <installdir>; <perldir>/perl ./controlcancel.pl &
# Ampersand in crontab makes the program uninterruptible. (Symbols in <>
should be
# exchanged for real values.)
#
print"$first $last\n";
print"1\n";
use strict;
print"2\n";
use NNTPClient; # Locally installed News::NNTPClient
print"3\n";
# <cfg>
my $NNTPServer = "just2write2.myftp.org";
print"4\n";
my $group = "swnet.politik";
print"5\n";
my $dir = "/var/www";
print"6\n";
my $delay = 0; # seconds
print"7\n";
# </cfg>
my $c = new News::NNTPClient($NNTPServer);
print"8\n";
$c->authinfo('xxxxxxxx','xxxxxxxxx');
print"9\n";
my ($first, $last) = $c->group("control.cancel");
print"10\n";
opendir CTRLCAN, $dir;
print"11\n";
my @files = grep /^$group\_(\d+)\.txt$/, readdir CTRLCAN;
print"12\n";
my $max = 0;
print"13\n";
foreach $_ (@files) {
$_ =~ m/(\d+)\.txt$/;
print"14\n";
if($1 > $max) {
$max = $1;
print"15\n";
}
}
my $inFile = sprintf "$group\_%04d.txt", $max;
print"16\n";
open IN, '<', $dir . $inFile;
print"17\n";
my $line;
print"18\n";
read IN, $line, 80;
print"19\n";
close IN;
print"20\n";
$line =~ m/\$last=(\d+)/;
print"21\n";
$first = $1 + 1 if $1;
print"22\n";
my $file = sprintf "$group\_%04d.txt", $max+1;
print"23\n";
open OUT, '>', $dir . $file;
print"24\n";
print OUT "\$first=$first, \$last=$last\n";
print"25\n";
my $starttime = time;
print"26\n";
print OUT "\$starttime=$starttime\n\n";
print"27\n";
for(; $last >= $first; --$last) {
my $head = join('', $c->head($last));
print"28\n";
if($head =~ m/^Newsgroups:.*[\s|,]+$group.*$/m) {
print OUT $c->article($last);
print"29\n";
print OUT "\n\n";
print"30\n";
}
sleep $delay;
print"31\n";
}
my $stoptime = time;
print"32\n";
print OUT "\n\$stoptime=$stoptime\n";
print"33\n";
print OUT "\$elapsed=" . ($stoptime-$starttime) . " s\n";
print"34\n";
close OUT;
print"35\n";
__END__
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