this is a better phrasing of what I intended in System.exit return code isn't detected by bash eval. I need a bash script that
- runs an application (in my case it’s a java app)
- directs stderr to a file
- directs stderr + stdout to the terminal
- returns the exit code of the app
for some reason, this is hard to do, even though it’s seems to me like a standard config for enterprise applications…
Thanks!
[EDIT]
testing solutions by wrapping this script:
#!/bin/sh
echo "This is Standard Out"
echo "This is Standard Error" >&2
cat meow
This will do your requirements :
EXPLANATIONS
exec 2 >catch STDERR (if you provide a file on the right, STDERR will be redirected in this file and no more on the terminal)>( )is a bash process substitution (this create file descriptors in background)teeis there to both displays STDERR on the terminal & to save STDERR to the logfile