#!/boot/home/config/bin/python
#
#  Copy groups list from NNTP service.
#
#  This is many megabytes of drivel you rarely want, and is not
#  a good function to incorporate into the newsreader itself.
#
from socket import socket, SOCK_STREAM, AF_INET
import sys

def listout(fp, host):
	nntp = socket(AF_INET, SOCK_STREAM)
	nntp.connect((host, 119))

	nntp.send('LIST\r\n')

	while 1:
		txt = nntp.recv(16384)
		if not txt:
			break
		fp.write(txt)

if __name__ == '__main__':
	if len(argv) < 2:
		sys.stderr.write('Usage: getlist newserver\n')
	else:
		listout(sys.output, sys.argv[1])
