🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nn
Article #2440

nn folders -> mailbox format

#2440
From: Ofer Inbar
Date: Mon, 10 Feb 1992 17:43
57 lines
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>
Technical Details
Message-ID: <cos.697743822@chaos.cs.brandeis.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.nn.mbox.zip!sparky!uunet!ulowell!m2c!nic.umass.edu!noc.near.net!news.cs.brandeis.edu!chaos.cs.brandeis.edu!cos

Show Full Headers
Complete Article Headers
Message-ID: <cos.697743822@chaos.cs.brandeis.edu>
Subject: nn folders -> mailbox format
Date: Mon, 10 Feb 1992 17:43:42 +0000
From: cos@chaos.cs.brandeis.edu (Ofer Inbar)
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.nn.mbox.zip!sparky!uunet!ulowell!m2c!nic.umass.edu!noc.near.net!news.cs.brandeis.edu!chaos.cs.brandeis.edu!cos
Newsgroups: news.software.nn
Summary: this perl script will do the translation
Sender: news@news.cs.brandeis.edu (USENET News System)
Organization: Brandeis University
Lines: 57