Article View: news.software.readers
Article #48093Re: Automating Removal of Mailing List Mail With Slrn or Slrnpull
From: 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
Technical Details
Message-ID:
<slrn7hio99.u7q.davis@aluche.mit.edu>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp!not-for-mailReferences:
<924405383.479.38@news.remarQ.com>Show Full Headers
Complete Article Headers
Message-ID: <slrn7hio99.u7q.davis@aluche.mit.edu> Subject: Re: Automating Removal of Mailing List Mail With Slrn or Slrnpull Date: Sun, 18 Apr 1999 00:00:00 +0000 From: da...@space.mit.edu (John E. Davis) References: <924405383.479.38@news.remarQ.com> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp!not-for-mail X-Deja-AN: 467842068 X-Complaints-To: use...@eecs-usenet-02.mit.edu X-Trace: eecs-usenet-02.mit.edu 924410172 10713 18.75.2.45 (18 Apr 1999 04:36:12 GMT) Organization: Center for Space Research User-Agent: slrn/0.9.5.5 (UNIX) Reply-To: da...@space.mit.edu NNTP-Posting-Date: 18 Apr 1999 04:36:12 GMT Newsgroups: news.software.readers,alt.lang.s-lang