O'Reilly logo

Solaris™ Operating Environment Boot Camp by Dominic Butler, David Rhodes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

M4

Before we look at how it's used with sendmail, let's have a brief look at m4 itself. We've just mentioned that it is a macroprocessor, but what exactly does that mean, and what does it do?

Given a text file as input, m4 will scan the file looking for predefined tokens it has been told about. If it finds any, it will perform a transformation on them, which will differ depending on what tasks we would like it to perform. Let's look at an example to show how this works in practice:

hydrogen# m4
define('eg', 'this is the first example')

eg
this is the first example
hydrogen#

First we can see that m4 reads standard input and writes to standard output. After starting the program, we've defined a macro that will substitute the string “eg” for the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required