Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there an option to run a mysql lookup in the pipe driver of exim?

MYSQL_Q_SCRIPT=SELECT script FROM MYSQL_EMAILTABLE WHERE domain='${quote_mysql:$domain}' AND local_part='${quote_mysql:$local_part}'
command = "${lookup mysql {MYSQL_Q_SCRIPT}{$value}

I am always getting an error like this:

"Expansion of "${lookup" from command "${lookup mysql {SELECT script FROM emails WHERE domain='${quote_mysql:$domain}' AND local_part='${quote_mysql:$local_part}'}{$value}}" in run_script transport failed: missing lookup type"

The problem is that exactly the same query works fine in the appenddriver. So I do not see the mistake.

share|improve this question
up vote 0 down vote accepted

Whitespace is handled differently in command option in the pipe transport. Before any expansion is performed, the contents of command are split by white space, and then expansion is performed on each element in turn. To quote TFM:

The expansion is applied to each argument in turn rather than to the whole line. For this reason, any string expansion item that contains white space must be quoted so as to be contained within a single argument. A setting such as

command = /some/path ${if eq{$local_part}{postmaster}{xx}{yy}}

will not work, because the expansion item gets split between several arguments. You have to write

command = /some/path "${if eq{$local_part}{postmaster}{xx}{yy}}"

to ensure that it is all in one argument. The expansion is done in this way, argument by argument, so that the number of arguments cannot be changed as a result of expansion, and quotes or backslashes in inserted variables do not interact with external quoting. However, this leads to problems if you want to generate multiple arguments (or the command name plus arguments) from a single expansion. In this situation, the simplest solution is to use a shell. For example:

command = /bin/sh -c ${lookup{$local_part}lsearch{/some/file}}
share|improve this answer
thx, the problem with the whitespaces combined with the fix argument count was the problem – user28047 Apr 2 '10 at 16:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.