[Tutor] automatic account destruction

Lloyd Kvam pythonTutor at venix.com
Sun Apr 18 21:55:21 EDT 2004


On Sun, 2004-04-18 at 13:09, jb wrote:
> On Sun, Apr 18, 2004 at 02:09:00AM -0400, Kirk Bailey wrote:
> > I give people free email accounts. From time to time, I have the task 
> > of searching for abandoned accounts and removing them, which is a time 
> > consuming chore. This is a bother, world class. So I am building a 
> > script which opens the first line of every email popbox and extracts 
> > the first line. This is formatted as:
> > "From idiot1 at netzero.net Fri Nov 9 00:30:27 2001"
> > (quotemarks mine, not found in data)
> > and I must crunch as needed to turn it into SECONDS SINCE THE EPOCH.
> 
> you can use the os.stat function to do something similar (with the st_ctime
> field) without reading the file.  st_ctime is in seconds since the epoch, if
> i remember correctly.
> 
> > I then add a magic number to it (the number of seconds in 2 months), 
> > and compare it to NOW. If that sum is smaller than NOW, the message is 
> > VERY OLD, and we assume the account is abandoned, and delete it. We 
> > repeat this loop for every popbox in the directory, which contains 
> > nothing else BUT mailboxes, glob.glob('*.') to the rescue here.
> > 
> > This script is still in alpha stage, but I thought the list may find 
> > the process to do this crunching intresting.
> > 
> > I am unsure how to have a script run a su function. Sure,
> > os.system('rmuser'+filename)
> > comes to mind, but will FreeBSD accept such commands from a script 
> > running as a cronjob?
> 
> if you really want that you can run such a script in root' crontab, or
> use sudo and a (NOPASSWD) option.  however, running rmuser automatically
> seems a bit scary!  i would advocate the use of a confirmation step 
> somewhere in this process :)
> 
> > I will post the incomplete script on the tinylist site. Click THIS
> > http://www.tinylist.org/abandontest.txt
> > to view it.
> > 
> > Please keep in mind this script is untested as of yet and can use LOTS 
> > of work, and I welcome advice. As always, it is COPIOUSLY commented.
> > 
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
-- 

Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-653-8139
fax:	801-459-9582




More information about the Tutor mailing list