[Info-vax] Editors, was: Re: VT keyboard replacement
Phillip Helbig undress to reply
helbig at asclothestro.multivax.de
Mon Nov 22 15:49:55 EST 2021
In article <P5SdnQcKt_xOTAb8nZ2dnUU7-RfNnZ2d at supernews.com>, Alan
Frisbie <Usenet03_REMOVE at flying-disk.com> writes:
> On 11/22/21 08:52, Ian Miller wrote:
> >
> > but does TECO work on x86 yet? :-)
> >
>
> You beat me to it! :-)
>
> While I don't use TECO daily, there are times when it is the
> only suitable tool. One customer has an annual (yes, just once
> a year) job that involves extracting data from a vendor's report
> file. We considered other approaches, but eventually concluded
> that TECO was the right tool for the job, by a long shot.
>
> Documenting it was fun!
>
> Depending on the task at hand, I may use TPU, EDT, vi(m), notepad
> or TECO. What matters is which one is most suitable for the job.
Time to repost this gem (which I see I've had for a quarter of a
century!). I wonder how many would understand it without the comments.
>Newsgroups: comp.os.vms
>Path: news.rrz.uni-hamburg.de!news.dkrz.de!dscomsa.desy.de!news.belwue.de!scsing.switch.ch!newsstand.cit.cornell.edu!news.kei.com!world!mv!mv.mv.com!morris
>From: morris at mv.mv.com (Skipper W. Morris)
>Subject: Tool to convert U**x mail to VMSMail
>Message-ID: <DK8E95.Dt1 at mv.mv.com>
>Organization: MV Communications, Inc.
>Date: Wed, 27 Dec 1995 06:05:28 GMT
>X-Nntp-Posting-Host: mv.mv.com
>Lines: 241
VMS Mail lovers,
I worked up the little gem below after another frustrating day of
trying to find a reasonable way to deal with lots of mail. It converts U**X
mail file folders to VMS mail files/folders/messages.
Bug reports/fixes/comments/etc, are appreciated.
enjoy
/Skip Morris
----------------------------------cut here------------------------------------
$ set noon ! 'f$verify(0)'
$!+
$! CONVERT_MAIL.COM V1.0, Skip Morris, "morris at mv.mv.com", 26-Dec-95
$! Input paramters:
$! P1 = The file(s) you want to convert.
$! P2 = Output VMS Mail file.
$! P3 = VMS Mail folder to store mail (defaults to input file name).
$! P4 = if nonnull then only convert to Mail11 V3.
$! Wildcard directory/filename inputs are permitted.
$! Use from batch by:
$! "$ submit convert_mail /param="DISK$FOO:[SOURCE...]*.txt;"
$! Max supported message count per input file is 16,777,215 since
$! that's all that could fit in the available return status fields.
$! Any '"' char's in personal name are blown away as VMSMail barfs on 'em.
$! Any special char's in addresses string cause address to be quoted.
$! Warning!! properly formatted unix mail file assumed. Not much checking.
$!-
$ default = f$envi("procedure")
$ if f$parse(p1,,,"name") + f$parse(p1,,,"type") + f$parse(p1,,,"version") -
.eqs. ".;" then p1 = p1 + "*.*;" ! cause directory input to be wildcard
$ search_file = f$parse(p1)
$ wildcard = f$loca("*",search_file) .ne. f$leng(search_file) .or. -
f$loca("%",search_file) .ne. f$leng(search_file) .or. -
f$loca("...",search_file) .ne. f$leng(search_file)
$ output_file = f$parse(p2,"mail.mai;",p1)
$ temp_file = f$parse("mail_"+f$getjpi("","pid")+".tmp;",output_file,default)
$ v3only = p4 .nes. ""
$main_loop:
$ input_file = f$search(search_file)
$ if input_file .nes. ""
$ then
$ write sys$output "Converting ",input_file," to Maill11V3 format..."
$ folder = f$parse(input_file,,,"name")
$ call convert_unix_mail 'input_file' 'temp_file'
$ ! return status has line count encoded in return status value
$ msg_count = ($status .and. %x07fffff8) / 8
$ if .not. v3only
$ then
$ write sys$output f$fao("Converting to ISAM file !AS folder !AS...", -
output_file,folder)
$ call convert_vms_mail 'temp_file' 'output_file' 'folder'
$ delete 'temp_file'
$ else
$ write sys$output f$fao("New file is !AS.",output_file)
$ rename 'temp_file' 'output_file'
$ endif
$ write sys$output f$fao("...done, !ZL message!%S processed.",msg_count)
$ if wildcard then goto main_loop
$ endif
$ exit
$!
$CONVERT_VMS_MAIL: SUBROUTINE
$ tempcom = f$parse("mail-"+f$getjpi("","pid")+".tmp;",p2,f$envi("procedure"))
$ create 'tempcom'
$ open/append file 'tempcom'
$ write file "$ mail"
$ write file "set file ",p1
$ write file "copy/all ",p3," ",p2,"/noconfirm"
$ write file "exit"
$ close file
$ @'tempcom'
$ delete 'tempcom'
$ exit
$ENDSUBROUTINE
$!
$CONVERT_UNIX_MAIL: SUBROUTINE
$ teco = "$teco32 teco"
$ unix_mail_file = f$search(f$parse(p1))
$ if unix_mail_file .eqs. "" then exit 4
$ temp_file = f$parse(p2)
$ if temp_file .eqs. "" then exit 4
$!
$ if f$trnlnm("tec$memory") .nes. "" then deassign tec$memory
$ assign/user 'unix_mail_file' mail$in
$ assign/user 'temp_file' mail$out
$ assign/user _nla0: sys$output ! comment this line out to vfy teco execution
$ define/user tec$init "96ee"
$ teco
! goto top, case match exact, load <cr><lf> qu, qt tokens illegal Mail-11!
j1^x13^uu`10:^uu`^ut-` ! Add illegal in "From:" after "-" char!
9^uv`32:^uv`13:^uv`:^uv.:%@!^=/[]` ! qv contains sendmail delimiter tokens!
ermail$in`ewmail$out` ! open input, output files!
!main loop for each msg!
<%q ! start loop, increment msg counter!
b,.pb,.ka ! page out previous, get new!
12i` ! insert <ff> at msg start!
.ua ! store msg top in qa!
s^el^equ` ! srch 1 blank lines!
.ub ! store end of headers qb!
qajl2r ! go end of initial "From" line!
.-4,.xm ! get year in qm!
5r.uc ! qc at end of timezone/timeofday!
r-s `::s^ea`"s2r.ucr-s `' ! if alpha timezone then backup!
.,qcxn ! get time in qn!
.-1uc-2s `.,qcxo ! 1-2 digit day-of-month in qo!
3r-s ` ! go to start of month!
.,.+3xp ! get month in qp!
qaj ! search "From: " header!
qb-qa,:s^elFrom: `"s ! if successful!
-d9i` ! then change space to tab!
0l1xlkqajgl-l ! move line to top!
6c.uc ! save start of address qc!
0,0xc0,0xl ! init qc(pers nam), ql(addr)!
0a-34"e ! if 'From: "pp" <aa>' sntx!
c1:fb" `"s ! then if ending '" '!
1:fb<`"s ! then if find starting '<'!
1:fb>`"s ! then if ending '>' found!
qcj ! then go start pers name!
dqb-1ub ! delete leading '"', fixup qb!
s"`-dqb-1ub ! find ending '"', del, fix qb!
qc,.xc ! store pers name qc!
qc,.k ! kill pers name!
dqb-1ub ! delete space end pers name!
s<`-dqb-1ub.ud ! find starting '<' and delete!
s>`-dqb-1ub ! find ending '>' and delete!
qd,.xlqd,.k ! store addr in ql and kill!
|46^t.:=69^t1:=77^tqq=0tt ! else bad msg fmt, out err msg!
' ! endif!
' ! endif!
| 1:fb"`"s ! else if 'From: "aa"aa (pp)' syntax!
1:fb (`"s ! then if ' ('!
1:fb)`"s ! then if ending ')' found!
qcj ! then go start addr!
s (`-2dqb-2ub ! delete ' (', fix qb!
qc,.xlqc,.k ! put addr ql, delete!
s)`-dqb-1ud ! go end pers, del ')', fx qb!
qc,.xcqc,.k ! put pers name qc, delete!
|46^t.:=69^t2:=77^tqq=0tt ! else bad msg fmt, out err msg!
' ! endif!
|qcjl2rqc,.xlqc,.k0,0xc ! else assume 'From: "aa"aa' sntx!
' ! endif!
|46^t.:=69^t3:=77^tqq=0tt ! else bad msg fmt, output err msg!
' ! endif!
' ! endif!
| 1:fb <`"s ! else if 'From: pp <aa>' sntx, if ' <'!
1:fb>`"s ! then if ending '>' found!
qcj ! then go start pers name!
s <`-2dqb-2ub ! find starting ' <' and delete!
qc,.xc ! store pers name qc!
qc,.k ! kill pers name!
s>`-dqb-1ub ! find ending '>' and delete!
qc,.xlqc,.k ! store addr in ql and kill!
|46^t.:=69^t4:=77^tqq=0tt ! else bad msg fmt, output err msg!
' ! endif!
| ! else!
1:fb (`"s ! if 'From: aa (pp) sntx, if ' ('!
1:fb)`"s ! then if ending ')' found!
qcj ! then go start addr!
s (`-2dqb-2ub ! delete ' (', fix qb!
qc,.xlqc,.k ! put addr ql, delete!
s)`-dqb-1ud ! go end pers, del ')', fix qb!
qc,.xcqc,.k ! put pers name qc, delete!
|46^t.:=69^t5:=77^tqq=0tt ! else bad msg fmt, outpt err msg!
' ! endif!
|qcj ! else assume single addr case!
::s<`"s-ds>`-dqb-2ub' ! handle case 'From: <aa>'!
l2rqc,.xlqc,.k0,0xc ! assume 'From: aa' syntax!
' ! endif!
' ! endif!
' ! endif!
qcjgl.ud ! go end "From:", insert addr!
qcj<qd-.,s^egt`; ! loop find illegal chars addr!
-s^egv`i"`s^egt` ! quote previous delimiter token!
s^egv`ri"`qb+2ubqd+2ud ! quote next sendmail delimiter token!
> ! end loop!
:qc"g ! if pers name nonnull!
qdji `qb+1ub ! then insrt space delimiter!
i"`gci"`qb+2ub ! insrt pers nam w/quotes!
' ! endif!
|qajiFrom:`9i` ! else insrt "From:" anyway!
i"<unknown>"`13i`10i`qb+19ub ! create "<unknown>" from, fixup qb!
' ! endif!
qajqb-qa,:s^elTo: `"s ! if 'To:' header found!
-d9i` ! then chg space to tab!
l::s `"s-3dqb-3ub ! if additional 'To:' header lines!
<::s `;-dqb-1ub>i `qb+1ub ! then append & kill leading spaces!
l::fs `To:` ! Add 'To:' hdr if more addressee!
' ! endif!
-l1xlkqajlgl ! move 'To:' line to new loc!
|qajliTo:`9i`i`13i`10i`qb+6ub ! else insert empty 'To:'!
' ! endif!
qajqb-qa,:s^elCc: `"s ! if 'Cc:' header found!
-3diC:`9i` ! then do same stuff!
l::s `"s-3dqb-3ub ! if additional 'Cc:' header lines!
<::s `;-dqb-1ub>i `qb+1ub ! then append & kill leading spaces!
l::fs `Cc:` ! Add 'Cc:' hdr if more addressee!
' ! endif!
-l1xlkqaj2lgl
|qaj2liCC:`9i`i`13i`10i`qb+6ub ! else insert empty 'CC:'!
' ! endif!
qajqb-qa,:s^elSubject: `"s ! if 'Subject:' found!
-5di:`9i`qb-3ub ! then do it again!
<::s `"u0;'-dqb-1ub> ! delete leading spaces in Subj line!
0l1xlkqaj3lgl ! move Subj line to Mail-11 header!
|qaj3liSubj:`9i`i`13i`10i`qb+8ub ! else!
' ! endif!
13i`10i`qb+1ub ! mark end of Mail-11 hdr!
qajl2r ! goto end of From: line!
.uc ! mark current pos in qc!
i `goi-`gp ! insert timestmp dlmtr,yy,mm!
3r0a&223i`d0a&223i`d0a&223i`d ! upcase month!
i-`gmi `gn ! add rest of timestamp!
.-qc+qbub ! fixup qb!
qbj-l ! goto end of headers!
<n^el^equ`; ! loop to find blank line!
.-z"ea'::sFrom `"s0l0;' ! if endbuff append, if newmsg exit loop!
::s>From `"sfrFrom `|-l'> ! replace '>From ' hack, next loop!
::sFrom `;0l ! exit loop if no more messages!
>`` ! end main loop!
!erase buffer, load local DCL symbol "c_line_count" with line
count by: creating appropriate teco command, loading it in Q
register A, and executing it!
ji:egsym msg_count `qq\27i`b,.xab,.kma``
ex`` ! exit with status!
$!
$! exit and (hack alert) pass back count as part of return status in the
$! facility number and message number fields (set the suppress msg, customer
$! specific, and success status bits just to be politically correct).
$ if f$inte(msg_count) .le. %x07fffff8/8 ! 16777215 in decimal
$ then exit (f$inte(msg_count)*8).or.%x18000003
$ else exit 1 ! pass back count = 0
$ endif
$ENDSUBROUTINE
More information about the Info-vax
mailing list