Columbia MM
MM Manual

USING MM WITH UNIX STANDARD INPUT AND OUTPUT

One of the characteristics of UNIX is that processes (commands and programs) can pass data to each other, an operation known as piping. MM has a few features to pipe text between messages and external (non-MM) commands as standard input and output.


INSERTING COMMAND OUTPUT INTO A MESSAGE YOU ARE WRITING

You might want to redirect the output of a command into a message, so you can include the output in the text you are writing.

If you are using MM's text mode to write the message, use control-p "to run a program and insert output". In this example, you insert a list of your files into the message, by using the ls command.



 Message (End with CTRL/D or ESC
  Use CTRL/B to insert a file, CTRL/E to enter editor, CTRL/F to run text
  through a filter, CTRL/K to redisplay message, CTRL/L to clear screen and
  redisplay, CTRL/N to abort, CTRL/P to run a program and insert output.):

Here are my files:

[control-p]
Command: ls
[Done]

[escape]
S>


The output of the ls command is not shown on your screen, but the response [Done] tells you that the command was run successfully. If there was a problem, you would see sh: and then the usual error message from the UNIX shell; if you mistyped la for example it would respond with sh: la: not found.

At the S> prompt, use the display command to see the entire message, including the output from the command.

If you are using Emacs to write the message, you can use the standard Emacs command to insert output of a shell command, which is meta-1 meta-! followed by the command. The following shows the command line window at the bottom of the screen; actually M-1 M-! will appear briefly before you see the prompt Shell command.



-----Emacs: *MM Outgoing*          (Text Fill)----All--------------------------
Shell command: ls




-----Emacs: *MM Outgoing*          (Text Fill)----All--------------------------
Mark Set


At the end of the sequence above, the cursor (point) is placed at the beginning of the command output, and mark is at the end, so you can delete with just control-w if you change your mind. You can see the command output, and you can edit it just like the rest of the message.


SENDING A MESSAGE YOU RECEIVED AS INPUT TO A COMMAND

The reverse of the preceding would be to take a message you received and send it as input to a command. The command would presumably process the text in some way. Use the list command with the special syntax |"command" (pipe, quote, command, quote). At the MM> prompt, add the message-sequence at the end; at the R> prompt, list acts on the message just read.

In the first example, message 16 is piped to a print command. The second example, perhaps contrived, the command used, grep, writes to standard output, so the result is displayed on screen (it shows lines containing the word topology, perhaps useful if the message contains a table of one-line items as this one seems to).



MM>list |"lpr -h -Piab1" 16
MM>list |