0

I'm running a script on a Bourne shell, eg not bash (actually the sh from BusyBox 1.23.2).

As asked & answered in this question, I'd like to "catch" error messages issued by commands within my script, and preappend a string to have them stand out in the log file.
However contrary to the answer provided in the linked question, I cannot use process substitution because the shell is not bash.

I'm redirecting all outputs to a log file:

#exec 3>&1 4>&2 >>$LOGFILE 2> >(sed 's/^/ *** ERROR:  /' >&1)
#  -->  -sh: syntax error: unexpected redirection
exec 3>&1 4>&2 >>$LOGFILE 2>&1
luneart
  • 101
  • My first reaction is that you can't, you need a more capable shell than a plain POSIX shell. You might get a better answer on http://unix.stackexchange.com or http://stackoverflow.com – glenn jackman Sep 18 '15 at 13:33
  • yeah, I'll admit I don't have much hope. I'm used to bash, this is so frustrating! I have to stick with that shell because I don't want to recompile the OS at each new update of the system. I'll try SO, fingers crossed! Thanks for your attention though. – luneart Sep 18 '15 at 19:18

0 Answers0