Somewhat re-asking my question since I mistakenly asked in SO with a bash shell tag and figured this is a more appropriate place.
I'm writing a shell script within AWS DataPipeline that connects to a relational database, and the exit code is 0 even for SQL errors, so I need to capture + redirect stderr.
I'm redirecting stderr to another file to check for its contents, but still want stderr to be populated. The reason is that DataPipeline captures all the stderr and stdout and puts them all into 1 log. It's not capturing the stderr from the failed sql command because of the redirection. Is there a way to still have stderr populated? What I currently have is:
/bin/snowsql -f /home/scripts/dev/dev.sql 2> /home/scripts/dev/stderr.txt
The following worked with Bash:
/bin/snowsql -f /home/scripts/dev/dev.sql 2> >(tee /home/scripts/dev/stderr.txt >&2)
I can't find the proper syntax for the process substitution for shell. What's the equivalent for doing above in shell?
sh
,#!/bin/sh