On Tue, Jan 20, 2026 at 05:37:38PM +0100, arjen-postfix-users-212--- via 
Postfix-users wrote:
> Hi list,
> 
> sorry in advance for a possible dumb question.
> 
> - output is printed to the console:
>   postfix tls new-server-cert
> - output is printed to the console:
>   postfix tls new-server-cert 2>&1
> - output is not printed:
> postfix tls new-server-cert 2>/dev/null
> - empty file /tmp/certinfo:
>   postfix tls new-server-cert 2>/tmp/certinfo
> - empty file /tmp/certinfo:
>   postfix tls new-server-cert >/tmp/file 2>&1
> 
> I wanna catch the output to parse it and run
>   postfix tls deploy-server-cert
> 
> What am I doing wrong? Any suggestions?

These messages are written to the system log using postlog(1), which
also prints them to stderr, provided stderr is attached to a terminal,
but as soon as you redirect the output to a file, postlog(1) obligingly
writes only to the system log.

The socat(1) program can work around this limitation:

    $ socat - EXEC:"postlog -t experiment 'this is a 
test'",pty,stderr,setsid,sigint,echo=0 2>&1 | cat
    experiment: this is a test

    # grep 'this is a test' /var/log/postfix/log
    Jan 21 03:54:07 amnesiac experiment[3386510]: this is a test

So you can run "postfix tls ..." inside a socat(1)-managed PTY.

-- 
    Viktor.  🇺🇦 Слава Україні!
_______________________________________________
Postfix-users mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to