Why do i get a syntax error for "[...] 2> >(tee -a $logfile >&2) [...]" in a script when run as rpm preinstall scriptlet, but not when script runs from commandline?
The purpose of that construct is to allways forward stderr just to the log file, but to have stderr to both, the logfile and the console.
here the complete example script:
#!/bin/bash
LOGFILE=/tmp/example.log;
if mkdir -v /tmp/example 1>>$LOGFILE 2> >(tee -a $LOGFILE >&2);
then
echo "ok";
else
echo "ko";
exit 1;
fi
When run as pre scriptlet of a rpm (build with the maven rpm plugin), i get the error message:
syntax error near unexpected token `>'
` mkdir -v /tmp/example 1>>$LOGFILE 2> >(tee -a $LOGFILE >&2);'
If i invoke the same script from commandline, i get "ok", as expected.
What do i have to do to make it work inside the rpm?
Thank you for helpfull answers.