🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nn
Article #5600

Re: mail-format (converting)

#5600
From: Ofer Inbar
Date: Sat, 19 Mar 1994 18:44
46 lines
2558 bytes
umshih02@cc.umanitoba.ca (jun shih) writes:
>Is there a way to convert saved nn file (non mail format) to a mail-format

The key difference is the absence of From_ lines at the beginning of
each set of headers.  You could manually add the From_ line for each
message, if it's a short file.  The format of a From_ line is:

From <user> <date>

The <user> field cannot contain any comments (i.e. the real name), and
the <date> should be in the same format returned by the Unix date command.

If it's a long folder, you can try to use this perl script I wrote
back when I had to convert a whole bunch of files to mail-format.  I
won't guarantee that it'll work - it takes the date from the Date:
header to put in the From_ line, and some mailers (notably elm 2.4)
can get really picky about what date formats they'll recognize.
Anyway, you could always modify the script if it doesn't work for you.

------------------------------------------------------------
#!/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@cs.brandeis.edu
  --  WBRS (BRiS)  --  WBRS@binah.cc.brandeis.edu  WBRS@brandeis.bitnet
 Brandeis University Computer Science Department         (617) 736-2700
 415 South Street, Waltham MA, 02254-9110        System Admin: 736-2717
Technical Details
Message-ID: <cos.764102697@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!gmd.de!xlink.net!news.dfn.de!news.dfn.de!zib-berlin.de!netmbx.de!Germany.EU.net!EU.net!howland.reston.ans.net!noc.near.net!news.cs.brandeis.edu!cos
References: <2lu665$lfu@canopus.cc.umanitoba.ca>

Show Full Headers
Complete Article Headers
Message-ID: <cos.764102697@cs.brandeis.edu>
Subject: Re: mail-format (converting)
Date: Sat, 19 Mar 1994 18:44:57 GMT
From: cos@cs.brandeis.edu (Ofer Inbar)
References: <2lu665$lfu@canopus.cc.umanitoba.ca>
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!gmd.de!xlink.net!news.dfn.de!news.dfn.de!zib-berlin.de!netmbx.de!Germany.EU.net!EU.net!howland.reston.ans.net!noc.near.net!news.cs.brandeis.edu!cos
Newsgroups: news.software.nn
Sender: news@news.cs.brandeis.edu (USENET News System)
Organization: Brandeis University
Lines: 46