use a single log file for stdout and stderr

This commit is contained in:
George Danchev 2011-07-02 17:55:04 +00:00
parent d2033fa31d
commit 8adba1d7c3

View File

@ -4,8 +4,8 @@ set -e
SELF=$(basename "$0") SELF=$(basename "$0")
GEN_DATA_DIR=releng_generated_data GEN_DATA_DIR=releng_generated_data
CLOG1=${GEN_DATA_DIR}/log.${SELF}.1 CLOG=${GEN_DATA_DIR}/log.${SELF}
CLOG2=${GEN_DATA_DIR}/log.${SELF}.2
PASSED_OPTIONS="" PASSED_OPTIONS=""
if [ "${1}" == "-cleanup" ]; then if [ "${1}" == "-cleanup" ]; then
@ -18,7 +18,7 @@ else
cat << HLP cat << HLP
${SELF} runs executables from CWD starting with releng_*. ${SELF} runs executables from CWD starting with releng_*.
stdout/stderr output stored in ${GEN_DATA_DIR}/log.* stdout/stderr output stored in ${CLOG}
${SELF} -rc [-keep] ${SELF} -rc [-keep]
${SELF} -cleanup ${SELF} -cleanup
@ -28,18 +28,19 @@ HLP
fi fi
######################################################## ########################################################
> ${CLOG1} > ${CLOG}
> ${CLOG2}
DSTART=`date --utc` DSTART=`date --utc`
printf "\n${SELF}: Started at ${DSTART}" printf "\n${SELF}: Started at ${DSTART}"
E1=`date '+%s'` E1=`date '+%s'`
# require ^releng_, avoid running (your)self explcitly # require ^releng_, avoid running (your)self explcitly
for s in `ls | grep ^releng_ | grep -v ${SELF} | sort -n`; do for s in `ls | grep ^releng_ | grep -v ${SELF} | sort -n`; do
if [ -x ${s} -a ! -d ${s} ]; then if [ -x ${s} -a ! -d ${s} ]; then
# tee(1) does trailing \n, which is unwanted in that case
printf "\n${SELF}: Running ./${s} ${PASSED_OPTIONS}..." printf "\n${SELF}: Running ./${s} ${PASSED_OPTIONS}..."
echo -e "\n${SELF}: Running ./${s} ${PASSED_OPTIONS}..." >> ${CLOG}
T1=`date '+%s'` T1=`date '+%s'`
set +e set +e
./${s} ${PASSED_OPTIONS} 1>>${CLOG1} 2>>${CLOG2} ./${s} ${PASSED_OPTIONS} &>> ${CLOG}
RET=$? RET=$?
T2=`date '+%s'` T2=`date '+%s'`
let TS="${T2} - ${T1}" let TS="${T2} - ${T1}"
@ -59,13 +60,12 @@ fi
printf "\n${SELF}: Stopped at ${DEND}.\n" printf "\n${SELF}: Stopped at ${DEND}.\n"
if [ "${1}" == "-cleanup" ]; then if [ "${1}" == "-cleanup" ]; then
rm -f "${CLOG1}" "${CLOG2}" rm -f "${CLOG}"
else else
E2=`date '+%s'` E2=`date '+%s'`
let ES="${E2} - ${E1}" let ES="${E2} - ${E1}"
printf "\n${SELF}: Total time elapsed ${ES} sec." printf "\n${SELF}: Total time elapsed ${ES} sec."
printf "\n${SELF}: stdout saved in ${CLOG1}." printf "\n${SELF}: stdout&stderr saved in ${CLOG}.\n"
printf "\n${SELF}: stderr saved in ${CLOG2}.\n"
fi fi
exit 0 exit 0