Dan Jacobson:
> Gentlemen, today we shall discuss searching for group names. E.g.,
> let's ask noffle what is the full name of that shortwave group.
echo "list active *shortwave*" | noffle --server
> I see I have written a bash function to do this:
> noffle_search_group ()
> {
> noffle -g | awk -F\\t '$1~'/$@/'{print $6,$1}' | sort -k 2
> }
> e.g.,
> $ noffle_search_group shortwave
> y rec.radio.shortwave
What about reading directly from the groupinfo database? I'd rather
backup the database before doing anything fancy, though. Here's a
simple example:
#!/usr/bin/env python
# 0755 noffle_active_re.py
# Tested at least once. Works for me but your mileage may vary.
# Requires Python incl. gdbm module
# Mirko Liss 2003-08-10
import gdbm, re, string, struct
import sys
groupdb = "/var/spool/noffle/data/groupinfo.gdbm"
def active_re( pattern ):
searcher = re.compile( pattern, re.IGNORECASE ).search
db = gdbm.open( groupdb, "r" )
matchlist = filter( searcher, db.keys() )
matchlist.sort()
for a in matchlist:
entry = db[a]
(first, last, remotelast, createdTime,
lastAccessTime) = struct.unpack( "iiiii", entry[:20] )
(server, description) = string.split( entry[20:-6], "\0" )
(postAllow, lastPostTime) = struct.unpack( "=ci", entry[-5:] )
# print groupname without "\0"
print a[:-1], last, first, postAllow
return
if len( sys.argv ) > 1:
active_re( sys.argv[1] )
else:
print "Usage: %s pattern" % sys.argv[0]
# End-Of-File
|