text

text

Look up in flat text files V8.7 and above

The text database-map type allows you to look up keys in flat text files. This technique is vastly less efficient than looking up keys in real databases, but it can serve as a way to test rules before implementing them in database form.

For the text database map, columns for the key and value are measured as an index. That is, the first column is number 0. To illustrate , consider the following mini-configuration file that can be used to check spelling:

 Kspell text /usr/dict/words Spell R$-      $: $(spell  $: not in dictionary $) 

The /usr/dict/words file contains only a single column of words. This rule shows that the key is (by default) the first column (index 0). And the value is (by default) also the first column (index 0).

For more sophisticated applications you can specify the key's column (with the -k switch), the value's column (with the -v switch), and the column delimiter (with the -z switch). To illustrate, consider the need to look up a user -id in the /etc/passwd file and to return the login name of the user to whom it belongs:

 Kgetuid text -k2 -v0 -z: /etc/passwd R$-      $: $(getuid  $) 

The lines of a password file look like this:

 ftp:*:1092:255:File Transfer Protocol Program:/u/ftp:/bin/sh 

The third column (where the columns are separated by colons) is the uid field. The first is the login name. Note that the -k and -v switches show these fields as indexes, where the first is 0 and the third is 2.

Note that if a file cannot be opened because it is unsafe (DontBlameSendmail), the following warning will be logged and printed:

 text map "  name  ": unsafe map file  filename  

This message will not be printed if the -o switch is specified with the database-map declaration.

Only a handful of database switches are available with this text type. The are listed in Table 23-26.

Table 23-26. The text database-map type K command switches

Switch

Description

-a

-a

Append tag on successful match

-D

-D

Don't use this database map if DeliveryMode= defer

-f

-f

Perform a case-insensitive search

-k

-k

Specify column for key or key name

-m

-m

Suppress replacement on match

-o

-o

This database map is optional

-q

-q

Don't strip quotes from key

-S

-S

Space replacement character

-T

-T

Suffix to append on temporary failure

-t

-t

Ignore temporary errors

-v

-v

Specify the value's column

-z

-z

Specify the column delimiter

The -d38.20 debugging command-line switch (-d38.20) is available to watch this text type.



Sendmail
sendmail, 4th Edition
ISBN: 0596510292
EAN: 2147483647
Year: 2002
Pages: 1174

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net