[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Very very very sorry, but please help



jason and jill wrote:
...
  >Last night I took over a listserv that basically had been left on cruise
  >control without a list owner for over a year.  Out of 1000 subscribers, a
  >couple of hundred are deadwood set NOMAIL, some of whom have been set that
  >way for years.
  >
  >Using a query to the listserv, I received a file that gives the email
  >addresses of all nomailed users, but a typical entry is:
  >
  >User "Bob Jones" is subscribed at address <bob@jones.com> and has
  >selected the following options:
  >
  >Followed by several lines listing all of his subscribers options and what
  >they mean.
  >
  >I want to just unsubscribe all these addresses.  As listowner, I can unsub
  >anyone by mailing listserv the command:
  >
  >del listname <address>
  >
  >A batch of commands can be done, at any length, but just doing:
  >del listname <addr1>
  >del listname <addr2>
  >del listname <addr3>
  >and so on.
  >
  >So what I need is a script that will extract just the email addresses,
  >with one address on each line, and then prepend "del listname" to each
  >address. 

I assume your file of users looks something like this:
======== begin ===============
User "Bob Jones" is subscribed at address <bob@jones.com> and has
selected the following options:
hjjkkj
adsfdsa
User "Fred Smith" is subscribed at address <fred@smith.com> and has
selected the following options:
agda,NOMAIL
User "John Doe" is subscribed at address <doe@gloop.com> and has
selected the following options:
afda
========= end ==============
  

This can be done with awk.

Create this file (call it deadwood.awk):
======== begin===============
/^User ".*" is subscribed at address </    {user = substr($0,
                                                   match($0, "<.*>"),
                                                   RLENGTH)}
/NOMAIL/        {printf("del listname %s\n", user)}
======== end ===============

Assuming your input file is called `file_of_users', run awk:

awk -f deadwook.awk file_of_users >delete_list

Running this on the example above gives this in `delete_list':
========= begin==============
del listname <fred@smith.com>
========= end ==============


If this doesn't work, mail me an extract from the file so I can see exactly
what it looks like.



-- 
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
               PGP key from public servers; key ID 32B8FAA1
                 ========================================
     "If my people, which are called by my name, shall 
      humble themselves, and pray, and seek my face, and 
      turn from their wicked ways; then will I hear from 
      heaven, and will forgive their sin, and will heal 
      their land."               II Chronicles 7:14 



Reply to: