program

Run an external program to look up the key V8.7 and later

The program type allows you to perform lookups via arbitrary external programs. The form for the declaration of this database-map type looks like this:

Kname program  /path  arg1 arg2 ...

The /path must be the full pathname to the program. Relative paths will not work, and attempts to use them will log the following error and cause the lookup to fail:

NOQUEUE: SYSERR(user): relative name: cannot exec: No such file or directory

The program is run as the user and group specified by the DefaultUser option (DefaultUser on page 1000) unless the RunAsUser option (RunAsUser on page 1083) is declared, in which case it will run as the user and group declared by that latter option.

The arguments to the program always have the key to be looked up added as a final argument:

Kname program  /path  arg1 arg2 ...key added here

This is the only way the key can be passed to the program. The key will specifically not be piped to the program’s standard input.

The value (result of the lookup) is read from the program’s standard output. Only the first MAXLINE-1 characters are read (where MAXLINE is defined in conf.h, currently as 2048). The read result is processed like an address and placed into the workspace (unless the -m switch is used with the K command).

To illustrate, consider the need to look up a user’s preferred address in an external relational database:

Kilook program /usr/sbin/ingres_lookup -d users.database

This program has been custom-written ...

Get sendmail, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.