From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,3246e4eabd3a921e X-Google-Attributes: gid1164f8,public From: beacom@nucth.physics.wisc.edu (John Beacom) Subject: Re: Conversion of mail folders VMS -> OSF dxmail Date: 1995/06/14 Message-ID: X-Deja-AN: 104450953 references: <3rmqom$ad@hermes.ridgefield.sdr.slb.com> organization: Nuclear Theory, UW - Madison newsgroups: comp.sys.dec In article <3rmqom$ad@hermes.ridgefield.sdr.slb.com> Apo Sezginer writes: > Is there a neat way of converting VMS mail folders to dxmail (OSF) > folders so that the tree structure and the message attributes (dates, etc) > are preserved ? yes, fortunately. 1. extract/all each folder and save those to files. get them to your unix box. 2. run the enclosed script on each file. clean up the messes. it seems to need to be gawk, and not awk. i forget why, but it has something to do with the from field. the script rearranges the headers pretty nicely. dxmail is an overlay to mh, so now you're done. if you use unix mailbox format (for /usr/ucb/mail, emacs' vm mode, etc), you need to keep hacking, since these are more picky about headers than mh is. in a proper unix header, there is a line like >From smith Wed Jun 14 12:03:54 1995 this is unix-mailbox biz. there is also the standard From: John Beacom as expected. i hacked in the "From smith .." lines in myself with a script. i just set them all to be "From daemon .." and at the same time. that line isn't too important, but it has to be there. ------ stolen script follows #! /bin/sh # $Header: /u3/acs/jdpeek/.bin/RCS.Z/vmsmail2mh,v 1.2 90/03/22 06:53:59 jdpeek Exp $ ### vmsmail2mh - split VMS mail messages from EXTRACT/ALL into MH folder ### Usage: vmsmail2mh [+folder] [...vmsmsg-files] ## ## AN EASY WAY TO TRANSFER VMS MAIL MESSAGES TO UNIX IS BY EXTRACTING ## ALL THE MESSAGES FROM A VMS MAIL FOLDER INTO A FILE... USE: ## MAIL> EXTRACT/ALL ## _file: FILENAME ## THEN, YOU CAN ftp THEM TO THE SYSTEM RUNNING MH. ## ## WHEN YOU GET THEM TO THE MH SYSTEM, vmsmail2mh WILL READ THROUGH ## THE FILE (OR STANDARD INPUT, IF YOU DON'T GIVE A FILENAME): ## - THE MESSAGES ARE SEPARATED BY FORMFEEDS (CONTROL-L). ## vmsmail2mh WILL CUT THEM INTO SEPARATE MH MESSAGES ## IN THE CURRENT FOLDER (OR +folder IF YOU GIVE ONE). ## - THE FORMAT OF THE VMS MAIL MESSAGE IS DIFFERENT. ## * Subj: LINES ARE CONVERTED TO Subject: LINES. ## * From: LINES ARE SPLIT INTO From: AND Date: LINES. ## ONLY THE FIRST Subj: AND From: IN EACH MESSAGE IS CONVERTED. ## ## BUG: VMS ADDRESSES LIKE: ## SMTP%"user@host" ## HOST::USER ## AREN'T CONVERTED. IN FACT, *NO* ADDRESSES ARE CONVERTED. # NOTE: PROGRAM HASN'T BEEN TESTED THOROUGHLY. # CHECK THE MESSAGES! # Placed in the public domain. Use at your own risk. # --Jerry Peek, 22 March 1990 dfltprot=600 # DEFAULT MESSAGE PROTECTION (IF NONE IN MH PROFILE) folopts="-fast -nolist -nototal -nopack -norecurse" mh=/usr/local/bin/mh mhprofile=/.mh_profile # READS MH PROFILE scanopts="-noclear -noheader -noreverse" case "$1" in [@+]?*) # IF $1 DOESN'T EXIST, folder WILL CREATE IT (SIGH). # THAT'S BECAUSE stdout IS REDIRECTED AWAY FROM TERMINAL. if $mh/folder $folopts "$1" >/dev/null then # GET PATHNAME OF FOLDER, LAST MESSAGE NUMBER: folpath="`$mh/mhpath`" || exit firstmsg="`$mh/scan -format '%(msg)' last`" || exit else echo "`basename $0`: no folder. quitting." 1>&2 exit 1 fi ;; *) echo "Usage: `basename $0` +folder|@folder [file] ('$1' doesn't start with + or @.)" 1>&2 exit 1 ;; esac if [ -n "$2" -a \( ! -r "$2" \) ] then echo "`basename $0`: quitting: can't read VMS file '$2'." 1>&2 exit 1 fi # GET PROTECTION MODE FROM MH PROFILE (IF NONE, USE $dfltprot): msgprot="`$mhprofile -b msg-protect`" || msgprot=$dfltprot # MAKE SHELL ARCHIVE FILE ON awk'S STANDARD OUTPUT. # PIPE IT INTO sh TO CREATE THE MESSAGE FILES... # needs to be gawk to get the subjects to work gawk "BEGIN { folpath=\"$folpath\" # STORE AS STRING, WITH QUOTES msgprot=$msgprot # STORE AS NUMBER (NO QUOTES) msgnum=$firstmsg"' # CHANGE FROM DOUBLE- TO SINGLE-QUOTES inmsg = 0 } # PROCESS MESSAGES. EACH MESSAGE STARTS WITH CONTROL-L. # HOPE THERE ARE NO LINES WITH JUST A CONTROL-L IN MESSAGES! { # MESSAGE STARTS WITH CTRL-L ON A LINE BY ITSELF. # PRINT SHELL COMMANDS AND RESET FLAGS: if ($0 ~ /^\014$/ && inmsg == 1) { printf "END-OF-%s/%d\n", folpath, msgnum # SET PROTECTION (INEFFICIENT; SHOULD DO ALL MSGS. AT ONCE) printf "chmod %d %s/%d\n\n", msgprot, folpath, msgnum inmsg = 0 } # AT START OF MESSAGE, PRINT START OF ARCHIVE AND SET FLAGS: if (inmsg == 0) { inmsg = 1 msgnum += 1 printf "/bin/cat > %s/%d << \\END-OF-%s/%d\n", \ folpath, msgnum, folpath, msgnum didsubj = 0 didfrom = 0 next } # TURN Subj: INTO Subject: AND SET FLAG TO MAKE SURE WE DO NOT # TRASH ANY OTHER Subj: LINES (LIKE IN FORWARDED MESSAGES). # STRIP DATE (14-MAR-1990 15:31:12.02) OFF END OF THE From: LINE # AND MOVE IT TO LINE OF ITS OWN, THEN SET FLAG LIKE ABOVE: if ($1 ~ /^Subj:/ && didsubj == 0) { $1 = "Subject:" didsubj = 1 print } else if ($1 ~ /^From:/ && didfrom == 0) { for (i = 1; i <= NF - 3; i++) printf "%s ", $i printf "%s\n", $(NF - 2) printf "Date: %s %s\n", $(NF - 1), $NF didfrom = 1 } else print }' $2 | # IF NO $2, WILL READ STANDARD INPUT... /bin/sh -e # EXIT ON ANY ERROR exit # RETURN STATUS FROM PIPE ABOVE -- ________________________________________________________________________ John F. Beacom beacom@nucth.physics.wisc.edu (608) 262-4697 Dept. Physics - Chamberlin Hall, Univ. of Wisconsin, Madison, WI, 53706 ------------------------------------------------------------------------