Date: 2012-07-31 04:12 pm (UTC)
vatine: Generated with some CL code and a hand-designed blackletter font (Default)
From: [personal profile] vatine
Do you want/need STDERR and STDOUT separated or in the same file?

If you're only after the latter, I think the following might do the trick (may be bash-only, may be POSICX-compliant, use with care, no warranties, etc, etc, so on and so forth):
exec 3>&1 # Save current stdout on fd 3
exec > /tmp/log 2>&1 # redirect stdout and stderr to the log file
tail -f /tmp/log >&3 &  # Start a tail
"$@"  # execute the passed-in command line
RV=$? # save exit status
kill %tail # kill the output
wait # wait for it to finish
exit $RV # and pass back the saved exit status


Simply pass in the script you want to log. If you want stdout and stderr archived separately, it gets a bit trickier. Also, you may want to use a sensible way of picking the log file.
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

jimx0r: (Default)
jimx0r

July 2012

S M T W T F S
1234567
891011121314
15161718192021
22232425262728
2930 31    

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 3rd, 2025 08:07 am
Powered by Dreamwidth Studios