Subject: VMS to Unix conversion.

From: Abe Philip <[email-masked]>
Date: Fri, 05 Jul 1996 13:32:06 -0400

I am trying to convert my VMS mail folders to unix mail folders to use 
with Pine.  I'm using the awk script that was posted to the pine 
discussion forum by Jim Clark on Jul 23 1995. Here is the script:

--------vmsmail.awk----------
# awk program to reformat VMS mail header for Unix mail
BEGIN   { sun = 0;      dname[sun] = "Sun"
          mon = 1;      dname[mon] = "Mon"
          tue = 2;      dname[tue] = "Tue"
          wed = 3;      dname[wed] = "Wed"
          thu = 4;      dname[thu] = "Thu"
          fri = 5;      dname[fri] = "Fri"
          sat = 6;      dname[sat] = "Sat"
          mname["JAN"] = "Jan"; firstof["Jan"] = sun
          mname["FEB"] = "Feb"; firstof["Feb"] = wed
          mname["MAR"] = "Mar"; firstof["Mar"] = wed
          mname["APR"] = "Apr"; firstof["Apr"] = sat
          mname["MAY"] = "May"; firstof["May"] = mon
          mname["JUN"] = "Jun"; firstof["Jun"] = thu
          mname["JUL"] = "Jul"; firstof["Jul"] = sat
          mname["AUG"] = "Aug"; firstof["Aug"] = tue
          mname["SEP"] = "Sep"; firstof["Sep"] = fri
          mname["OCT"] = "Oct"; firstof["Oct"] = sun
          mname["NOV"] = "Nov"; firstof["Nov"] = wed
          mname["DEC"] = "Dec"; firstof["Dec"] = fri
        }
 
//      { pagesep = 1; next }   # delay formfeeds
 
$1 == "From:" {
        if (!pagesep)           # not a new mail header
          {print; next  }
        if (NR>3) print ""      # substitute blank line for formfeed
        pagesep = 0; newmsg = 1
        # unread mail has final asterisk in VMS and Status: RO in Unix
                status = "Status: RO"
                if (substr($0,length($0),1) == "*") status = ""
        # reformat date/time from DD-MMM-YYYY HH:MM to Day Mmm DD 
HH:MM:00 YYYY
                i = 0
                if (NF > 4) i = NF - 4
                if (status == "") i = i-1
                dash = index($(3+i), "-")
                date = substr($(3+i), 1, dash - 1)
                month = substr($(3+i), dash + 1, 3); month = 
mname[month]
                year = substr($(3+i), dash + 5, 4)
        # find day-of-week (baseline = Jan 1, 1972, a Saturday)
                y = year - 1972
                leapdays = int(y/4) - int(y/100) + int(y/400) + 1
                d = y + leapdays + firstof[month] + date - 1 + sat
                if ((year % 4) == 0 || (year % 400) == 0)
                        if (month == "Jan" || month == "Feb")
                        --d     # adjust for date in Jan/Feb of a leap 
year
        if (date < 10) date = " " date
        # truncate time
                time = $(4+i)
                if (index($(4+i), ".") > 0) time = 
substr($(4+i),1,index($(4+i),".")-1)
        # modify address
                from = substr($2, 5, length($2)-5)
        print "From", from, dname[d % 7], month, date, time , year
        print "From: " from
        print "Date: " dname[d % 7], month, date, year, time
        next }
 
$1 == "Subj:" {print "Subject: ", substr($0, 7, length($0)-6)
        # "Status" after "Subj"
                if (newmsg = 1) {print status; newmsg = 0 }
         next }
{               # ordinary line
        print $0
        if (pagesep = 1 && newmsg = 0)  {pagesep = 0; print "" }
        next}

------ End Script ---------
The line which says:

//      { pagesep = 1; next }   # delay formfeeds

causes a syntax error when I run it using the command he suggested:

awk -f mail.awk oldmail.mai > oldmail

The syntax error is as follows:

awk: Syntax error near line 24
awk: bailing out near line 24

I'm not familar enough with awk to debug it myself although I did try 
removing the  '//' at the beginning of the line which causes it to say 
that there is an syntax error near line 26.
If I comment it out with '#' it runs but the file doesn't get converted. 
Anyone have any ideas or suggestions??

Any help would be greatly appreciated.

Thanks

Abe

-- Abe Philip -- [email-masked] -- http://umbc.edu/~abe -- 455-6723 -
 Univ. of Maryland Balto. County | If I were expressing UMBC's opinions,
 University Computing Services   | they'd probably make me wear a tie...
 Applications Group              |