Re: [exim] Reading the value of a macro from a shell script

Page principale
Supprimer ce message
Répondre à ce message
Auteur: Phil Pennock
Date:  
À: exim-users
Sujet: Re: [exim] Reading the value of a macro from a shell script
On 2007-12-20 at 17:37 +0000, Terry Burton wrote:
> Otherwise, is there a recommended way to obtain such values from a
> shell script without having to hardcode the value or grep the Exim
> config?


With well-defined data syntaxes and exiting after first match (anchored
to the start of the line) grep is good. It's certainly going to be
faster than launching the full MTA; further, a broken config file may
cause the MTA to complain, so your error handling logic just got a lot
harder.

% grep -m1 '^TLSCERTIFICATESDIR\b' /etc/exim/exim.conf
TLSCERTIFICATESDIR=/etc/ssl/services/exim

That does fall down if you pull in extra config files or use
redefinitions; presumably if you are then you can adjust your scripts
accordingly.

If you do want to "ask Exim", then you'll need to ask for the value of
an option set using the macro and then strip off the filename component:

% exim -bP tls_certificate
tls_certificate = /etc/ssl/services/exim/spodhuis-smtpmx.crt.pem

For anything except macros, Exim can use the arguments to -bP to output
it. If you think macros would be useful, file a feature request bug.
:)

-Phil