Operating System - OpenVMS
1751783 Members
5024 Online
108781 Solutions
New Discussion юеВ

Re: Usinge MIME within a PIPE

 
SOLVED
Go to solution
Steven Schweda
Honored Contributor

Re: Usinge MIME within a PIPE

> [...] How is this useful [...]?

It gets its result into MIME without being an
interactive editor (requiring user action for
proper operation)?
John Gillings
Honored Contributor

Re: Usinge MIME within a PIPE

>Anyway, from what I've read, there seems to
>be no way to pass some text to the MIME
>program that will wind up in the body of
>the msg. Correct?

Not correct. It does exactly what you want. The /EDIT= command creates the body of the message. The parameter passed to the command is a file name generated by MIME which it uses as the message body.

The procedure in my last reply gives you a 10 point answer. All the mechanisms you need to do precisely what you requested, using PIPE, 100% of the time.

If you're brave, you could also use the final PIPE command to do it in the least amount of code:

PIPE (WO "Line 1" ; WO "Line 2") | (in=F$TRNLNM("SYS$PIPE") ; WO "NEW/EDIT=""COPY ",in,""" mimefile.out" ; WO "ADD attachment" ; WO "SAVE" ; WAIT 00:00:01) | MCR MIME

The body of your message is
Line 1
Line 2

BUT you're depending on the 1 second delay in the second pipe stage to be long enough for the third pipe stage to kick off and start reading from the first stage. It's probably a 99.99% solution, but some day on a very busy system it will fail (I experimented with other mechanisms to synchronise the processes, but couldn't find one).
A crucible of informative mistakes
John Gillings
Honored Contributor

Re: Usinge MIME within a PIPE

Yet another way - as a one liner:

PIPE (-
WO "NEW/EDIT=""PIPE (WO """"Body1"""" ; WO """"Body2"""")|COPY SYS$PIPE"" mimefile.out" ; WO "ADD attachment" ; WO "SA
VE") | MCR MIME

Be careful with quotes!
A crucible of informative mistakes
Jack Trachtman
Super Advisor

Re: Usinge MIME within a PIPE

Sorry John, I'm just not groking how to use the /EDIT=dcl function. The MIME help text example is not clear to me.

So lets say I have file msg.txt that I want MIME to put into the msg body part of some file. along w/an attached file. What would I use:

$ MIME
MIME> NEW/EDIT=???
MIME> ADD attachement
MIME> SAVE
MIME> EXIT
John Gillings
Honored Contributor
Solution

Re: Usinge MIME within a PIPE

Jack,

> I'm just not groking how to use >the /EDIT=dcl function

Yes, MIME has chosen a rather odd way to do the message body. I can see why you might have trouble groking. And I agree, the help text isn't very helpful.

Perhaps this will help...

MIME> NEW myfile

creates "myfile" with MIME headers, yes? The default is /EDIT which invokes a default interactive text editor to create the body text. However, the /EDIT qualifier is more general than that, it can be any command which creates a file. If you type:

MIME> NEW/EDIT="MYCOMMAND" myfile

the MIME command executes your command (presumably with SPAWN), appended with the name of a temporary file. Something like:

$ MYCOMMAND SYS$SCRATCH:MIME$656F_MSG.TXT

Note that the file doesn't exist when the command is invoked. If it exists when the command completes, it will be inserted into the MIME file as the message body. It appears this is the only mechanism for specifying the message body.

So you can see how the default action is really just /EDIT="EDIT/EDT", resulting in:

$ EDIT/EDT SYS$SCRATCH:MIME$656F_MSG.TXT

>So lets say I have file msg.txt that I want
>MIME to put into the msg body

The simplest possibility I can think of is:

MIME> NEW/EDIT="COPY MSG.TXT" mimefile.out

That would be appended with the temp file name and become:

$ COPY MSG.TXT SYS$SCRATCH:MIME$656F_MSG.TXT

MIME would then include the contents of the file into the output file, and delete the temporary file.

I too find this rather odd, it may have made more sense to have /BODY=file, but I suppose the utility was designed to be interactive. It has a kind of "swiss army knife" generality appeal, but it's also a bit klunky.

The variations I've posted are just different ways of feeding some text into some command to generate a file, specified as the last token in the command.

I used two command procedure to investigate what /EDIT was doing:

TEST.COM
$ @TEST1 /OUTPUT=TEST.OUT "''p1'" "''p2'" "''p3'" "''p4'" "''p5'" "''p6'" "''p7'" "''p8'"
$ EXIT

TEST1.COM
$ SHOW SYM p%
$ DIR 'p1'
$ EXIT 1

execute a command:

MIME> NEW/EDIT="@TEST" newfile

and look in TEST.OUT.

(BTW, I believe it's possible to reopen a thread in order to award points... ;-)
A crucible of informative mistakes
Jack Trachtman
Super Advisor

Re: Usinge MIME within a PIPE

Excellent John! Not only have you patiently taken the time to explain the details I needed to be able to do exactly what I want, but you've educated me in some fine points!

Last question: how do I reopen this thread so I can add points?
Jon Pinkley
Honored Contributor

Re: Usinge MIME within a PIPE

At the top of a closed thread, the author (you) should see a "reopen thread" button, to the left of the "notify","reply" etc. buttons.

Jon
it depends
Jack Trachtman
Super Advisor

Re: Usinge MIME within a PIPE

Thanks again