Thread View: news.software.readers
4 messages
4 total messages
Started by Frank Hahn
Sun, 18 Apr 1999 00:00
Automating Removal of Mailing List Mail With Slrn or Slrnpull
Author: Frank Hahn
Date: Sun, 18 Apr 1999 00:00
Date: Sun, 18 Apr 1999 00:00
16 lines
1198 bytes
1198 bytes
Thanks to hints from John Davis, I have been able to use procmail to copy Mailing List mail to a directory and then use Slrn to read from that directory. These articles are copied to the appropriate directory sequentially. My question is, how do I delete this mail in an automated manor? With slrnpull, you can tell it to delete articles over so many days old. Can something similiar be setup? -- Frank Hahn
Re: Automating Removal of Mailing List Mail With Slrn or Slrnpull
Author: da... John E. Davis
Date: Sun, 18 Apr 1999 00:00
Date: Sun, 18 Apr 1999 00:00
97 lines
3284 bytes
3284 bytes
On Sun, 18 Apr 1999 03:16:23 GMT, Frank Hahn <fh...@zdnetmail.com>
wrote:
>My question is, how do I delete this mail in an automated manor?
>With slrnpull, you can tell it to delete articles over so many
>days old.
It is easy to write a script in your favorite language that does
something similar. It took me a few minutes to write the following
slang script (use, e.g., the slsh program distributed with slang 1.3.5
from ftp://space.mit.edu/pub/davis/slang/snapshots to execute this).
You would use this script like:
purge 21 ~/Mail/My_List/*
to purge files older than 21 days from ~/Mail/My_List. Use the form
purge -n 21 ~/Mail/My_List/*
to just get a list of files older than 21 days. Use this at your own
risk!
-------------------(cut here) 8<------------------------------------------
#! /usr/bin/env slsh
% -*- mode: slang -*-
_debug_info = 1;
static define purge_file (file, age, print_option)
{
variable st = stat_file (file);
if (st == NULL)
{
() = fprintf (stderr, "stat %s failed: %s\n", file, errno_string (errno));
return;
}
if (st.st_ctime >= age)
return;
if (print_option)
{
() = fprintf (stdout, "%s\n", file);
return;
}
if (-1 == remove (file))
() = fprintf (stderr, "remove %s failed: %s\n", file, errno_string (errno));
}
static define purge_usage ()
{
() = fprintf (stderr, "Usage: %s [-n] NUM-DAYS-OLD files...\n", __argv[0]);
() = fprintf (stderr, " Files older than NUM-DAYS-OLD be deleted.\n");
() = fprintf (stderr, " -n ==> Just print the files to be removed but do not remove them.\n");
exit (1);
}
static define main (argc, argv)
{
variable age, i, print_option, file;
if (argc < 3) purge_usage ();
i = 2;
print_option = 0;
if (argv[1] == "-n")
{
i++;
print_option = 1;
if (argc < 4)
purge_usage ();
}
age = __argv[i-1];
if (String_Type == _slang_guess_type (age))
purge_usage ();
age = _time() - atof(age) * 24 * 3600;
foreach (argv[[i:]])
{
file = ();
purge_file (file, age, print_option);
}
exit (0);
}
main (__argc, __argv);
--
John E. Davis Center for Space Research/AXAF Science Center
617-258-8119 One Hampshire St., Building NE80-6019
http://space.mit.edu/~davis Cambridge, MA 02139-4307
Re: Automating Removal of Mailing List Mail With Slrn or Slrnpull
Author: tsumme... tony summerfelt
Date: Mon, 19 Apr 1999 00:00
Date: Mon, 19 Apr 1999 00:00
102 lines
4135 bytes
4135 bytes
On 18 Apr 1999 04:36:12 GMT, John E. Davis wrote:
> slang script (use, e.g., the slsh program distributed with slang 1.3.5
now THIS is a true gem. i haven't really looked in the slang 1.3.5
directories beyond compiling it. i was wondering if something just like this
was possible with slang :)
it would be nice if this could be turned into a win32 executable...
> to just get a list of files older than 21 days. Use this at your own
> risk!
this is floating around on one or two linux distrubtions, it's in perl but
it will do pretty much the same thing...it's a little bit longer because it
checks for race conditions, but it's what i've been using here...
#!/usr/bin/perl
#
sub debug {
if($ENV{'DEBUG'}) { print STDERR $_[0],"\n"; sleep 0; }
}
sub dodir {
my(@dirlist,@dirlist1,$thisdir,$a,$mode,$mtime,$ctime,$atime,$thefile,
%skiplist,$dev,$ino,$thedev,$theino);
$thisdir=$_[0];
chdir($thisdir) || die("Couldn't change directories to $thisdir");
&debug("========== Starting $thisdir =============");
$thedev = $_[1]; $theino=$_[2];
($dev,$ino) = lstat(".");
if(($dev != $thedev) || ($ino != $theino)) {
die("Directory changed after cd: $thisdir");
}
do {
@dirlist = ();
opendir(THISDIR,".");
@dirlist1 = grep(!/^\.\.?$/,readdir(THISDIR));
closedir(THISDIR);
foreach $thefile (@dirlist1) { &debug("Dirlist1: $thefile"); }
foreach $thefile (keys %skiplist) { &debug("Skiplist: $thefile"); }
foreach $thefile(@dirlist1) {
if($skiplist{$thefile} != 1) {
push(@dirlist,$thefile);
} else { &debug("Didn't add ".$thefile." to dirlist"); }
}
if(scalar @dirlist <= 0) {
&debug("========== Ending $thisdir =============");
&debug("returned skiplist = ".scalar keys %skiplist);
chdir("..");
return(scalar keys %skiplist);
}
foreach $thefile (@dirlist) { &debug("Dirlist: $thefile"); }
foreach $thefile (shift(@dirlist)) {
(($dev,$ino,$mode,$a,$a,$a,$a,$a,$atime,$mtime,$ctime,$a,$a)
= lstat($thefile)) || die("Couldn't lstat $thefile");
SWITCH: {
if(-d $thefile) {
&debug("Removing directory $thisdir/$thefile");
if(&dodir($thefile,$dev,$ino) > 0) {
$skiplist{$thefile} = 1;
&debug("Put dir $thefile on skiplist");
} else {
&debug("Doing rmdir");
rmdir($thefile) || die("Couldn't remove dir:
$thisdir/$thefile");
&debug("Removed directory $thefile");
}
($dev,$ino) = lstat(".");
if(($dev != $thedev) || ($ino != $theino))
{ die("Directory changed after cd: $thefile"); }
last SWITCH;
}
if(time() > ($ctime+$age)) {
&debug("Removing $thisdir/$thefile with an atime of $atime");
unlink($thefile) || die("Couldn't remove file $thefile");
} else {
$skiplist{$thefile} = 1;
&debug("Put $thefile on skiplist");
}
}
}
&debug("Scalar dirlist = ".scalar @dirlist);
} while(true);
}
$age = shift(@ARGV) * 3600;
@topdirs = @ARGV;
die <<USAGE unless scalar @topdirs > 0;
Usage:
tmpwatch [maximum age, in hours] directory ...
Removes all old files in a directory, without any known race conditions.
USAGE
foreach(@topdirs) {
&debug("Top dir is $topdir");
($dev,$ino) = lstat($_);
&dodir($_,$dev,$ino);
}
Re: Automating Removal of Mailing List Mail With Slrn or Slrnpull
Author: fh... Frank Hahn
Date: Fri, 23 Apr 1999 00:00
Date: Fri, 23 Apr 1999 00:00
42 lines
2315 bytes
2315 bytes
On 18 Apr 1999 04:36:12 GMT, John E. Davis <da...@space.mit.edu> wrote:
>On Sun, 18 Apr 1999 03:16:23 GMT, Frank Hahn <fh...@zdnetmail.com>
>wrote:
>>My question is, how do I delete this mail in an automated manor?
>>With slrnpull, you can tell it to delete articles over so many
>>days old.
>
>It is easy to write a script in your favorite language that does
>something similar. It took me a few minutes to write the following
>slang script (use, e.g., the slsh program distributed with slang 1.3.5
>from ftp://space.mit.edu/pub/davis/slang/snapshots to execute this).
>You would use this script like:
>
I appreciate both yours and Tony Summerfelts' responses. This is
what I have come up with so far.
I read through the man page for the "find" command on a Solaris
system and it gave an example of something similiar to what I wanted.
After messing around with it for awhile, I finally got it to delete
the oldest files. I then made it executable.
Here is the script:
------------------------------------------
#!/bin/sh
#
find /var/spool/slrnpull/news/maillist/* \( -name '*' \)
-mtime +5 -exec rm {} \;
------------------------------------------
The above line beginning with "find" is just one line in my script.
I have run it three or four times and it seems to do what I want.
I realize there is probably a much better way to do this, but
this seems to work.
Thanks for the help.
--
Frank Hahn
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