Thread View: news.software.nn
4 messages
4 total messages
Started by Ofer Inbar
Mon, 10 Feb 1992 17:43
nn folders -> mailbox format
Author: Ofer Inbar
Date: Mon, 10 Feb 1992 17:43
Date: Mon, 10 Feb 1992 17:43
57 lines
2992 bytes
2992 bytes
I haven't had time to keep up with news for the past few months, so I
don't know what the current situation is, but I remember people were
looking for something to allow nn to save in mailbox format. I've
written a short perl script that will take an nn folder (a file of
messages saved from within nn using the s or S commands) and output
the same messages in Unix mailbox format, suitable for programs such
as elm and mailx.
You use this script in either of the following ways:
cat nnfolder | nn2mbox > mailboxfile
nn2mbox nnfolder > mailboxfile
Where nn2mbox is the name of the file containing the script.
This script makes some assumptions about headers in saved articles;
these assumptions are always true for me, but may not hold at other
sites. If you find some variation in how nn works at your site, or
the format of news headers, please send me some email. The
assumptions are:
- Each block of headers begins with a "Path:" header, which this
script drops.
- From: lines always follow this format: "From: address arbitrary-text".
For example, "From: user@host.domain (Real Name)"
Addresses of the form "From: Real Name <address>" will break the
script, but I have never seen such in an nn folder here...
Oh, and one last comment. I wrote this script for nn 6.4.14.
Although I've installed patchlevel 16 here, I never really looked to
see what was new. If pl16 introduced some new feature that allows you
to save in mailbox format, then my script is unecessary.
----------cut-here---------------------
#!/usr/bin/perl
while (<>)
{ if (/^Path: .*\w!\w/i)
{ &processheaders; }
else { print; }
}
sub processheaders
{ local ($lnum);
header: while (<>)
{ $headers[$lnum++] = $_;
last header if /^$/;
$from = $1 if /^From: *(\w+[@%!][\w@%!:]+)/i;
$date = $1 if /^Date: *(.*)/i;
}
warn "EOF inside a header block\n" unless /^$/;
print "From $from $date\n";
foreach (@headers) { print; }
}
----------cut-here---------------------
-- Cos (Ofer Inbar) -- cos@chaos.cs.brandeis.edu
-- WBRS (BRiS) -- WBRS@binah.cc.brandeis.edu WBRS@brandeis.bitnet
A cos is an abstraction for a stream or datagram channel, used in BSD
and BSD derivatives. -- Ben Tober <tober@wizvax.methuen.ma.us>
Re: nn folders -> mailbox format
Author: Gary Morris
Date: Wed, 12 Feb 1992 14:55
Date: Wed, 12 Feb 1992 14:55
11 lines
1111 bytes
1111 bytes
In <cos.697743822@chaos.cs.brandeis.edu> cos@chaos.cs.brandeis.edu (Ofer Inbar) writes: >...but I remember people were >looking for something to allow nn to save in mailbox format. I've >written a short perl script that will take an nn folder... What's wrong with just putting "set mail-format true" in your .nn/init? --GaryM -- Gary Morris Internet: GaryM@telesoft.com KK6YB UUCP: ucsd!telesoft!GaryM TeleSoft, San Diego, CA Phone: +1 619-457-2700
Re: nn folders -> mailbox format
Author: Ofer Inbar
Date: Sat, 15 Feb 1992 07:51
Date: Sat, 15 Feb 1992 07:51
47 lines
2492 bytes
2492 bytes
garym@telesoft.com (Gary Morris @wayward) writes:
>
>What's wrong with just putting "set mail-format true" in your .nn/init?
>--GaryM
Ahh, this is the feature of nn that 6.4.14 was lacking and 6.4.16 has.
But since, as I said, I hadn't fully searched through the new docs,
and had been absent from the newsgroup, I didn't know this. Anyway, I
guess the script is still useful for converting old nn folders to
mailboxes, or for when you thought you didn't need mailbox format and
find that you do. And it's an interesting academic excercise to
figure out how to do the transformation :-)
Here's an updated script that looks somewhat messier, but deals with
more cases. It also fixes a bug in the original that caused it to
leave out the domains on addresses in the "From " lines. Not a
serious bug, but a bug nonetheless.
----------
#!/usr/bin/perl
while (<>)
{ if (/^Path: .*\w!\w/i || /^Xref: *\w+[\w.,]+/i
|| /^Newsgroups: *\w+[\w.,]+/i)
{ &processheaders; } else { print; }
}
sub processheaders
{ local ($lnum);
$headers[$lnum++] = $_ if /^Newsgroups:/i;
header: while (<>)
{ $headers[$lnum++] = $_ unless (/^Path:/i || /^Xref:/i);
last header if /^$/;
$from = $1 if /^From: *(\w+[@%!.][\w@%!:.]+)/i;
$date = $1 if /^Date: *(.*)/i;
}
warn "EOF inside a header block\n" unless /^$/;
print "From $from $date\n";
foreach (@headers) { print; }
}
----------
-- Cos (Ofer Inbar) -- cos@chaos.cs.brandeis.edu
-- WBRS (BRiS) -- WBRS@binah.cc.brandeis.edu WBRS@brandeis.bitnet
"GUIs normally make it simple to accomplish simple actions and impossible to
accomplish complex actions." --Doug Gwyn (22/Jun/91 in comp.unix.wizards)
Re: nn folders -> mailbox format
Author: Fred Rump from home
Date: Sat, 15 Feb 1992 19:53
Date: Sat, 15 Feb 1992 19:53
24 lines
1493 bytes
1493 bytes
garym@telesoft.com (Gary Morris @wayward) writes: >In <cos.697743822@chaos.cs.brandeis.edu> cos@chaos.cs.brandeis.edu (Ofer Inbar) writes: >>...but I remember people were >>looking for something to allow nn to save in mailbox format. I've >>written a short perl script that will take an nn folder... >What's wrong with just putting "set mail-format true" in your .nn/init? the partial contents of my .nn/init are: set mail-format true set default-save-file /u/fr/.elm/folders/$F/ and still I get my saved news articles in /u/fr/News/group/name So what gives? Anybody know? fred -- W. Fred Rump office: fred@COMPU.COM Of what is oatmeal made? 26 Warren St. home: fred@icdi10.compu.com 48% of Americans said wheat Beverly, NJ. 08010 (Harper's) 609-386-6846 bang:uunet!cdin-1!icdi10!fr
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads