From reading the mod_substitute
documentation, I cannot find a single reference as to why you would think it would work with executing an external process (or forking a shell, or anything of that sort). So I would not consider this route to be a viable one.
mod_ext_filter
, on the other hand, seems adapted to what you wish to do. However, to quote its documentation:
This filtering mechanism is much slower than using a filter which is specially written for the Apache API and runs inside of the Apache server process
So, if I were you, I'd consider using a dynamic language such as PHP (which was initially written for this very use case), or eventually writing a very small C program to do what you want, as it would end up much faster, and it isn't too hard.
Now, if you want to persist with your idea, don't use /bin/echo
. The substitution you wrote in "$(sed -E "1s/myString/&$(date +"%T.%3N")/")"
requires a shell, and /bin/echo
will not spawn one. Therefore, you need to either write a script (solution I would recommend), or at least call /bin/sh
(or /bin/bash
if you're so inclined) with the proper arguments: -c 'var="$(date +"%T.%3N")"; sed -E "1s/myString/&$var/"'
.
It's really hacky, and I maintain a PHP script or a C program would be simpler in the long run, but to each their own.