I have written a wrapper in bash, which calls other shell scripts. However, I need to print only the output from the wrapper, avoiding the output from called scripts, which I am basically logging into a log file.
Elaborating…..
Basically I am using a function as
start_logging ${LOGFILE}
{
Funtion1
Funtion2
} 2>&1 | tee -a ${LOGFILE}
Where start logging is define as:- (I could only understand this function partially)
start_logging()
{
## usage: start_logging
## start a new log or append to existing log file
declare -i rc=0
if [ ! "${LOGFILE}" ];then
## display error and bail
fi
local TIME_STAMP=$(date +%Y%m%d:%H:%M:%S)
## open ${LOGFILE} or append to existing ${LOGFILE} with timestamp and actual command line
if [ ${DRY_RUN} ]; then
echo "DRY_RUN set..."
echo "${TIME_STAMP} Starting $(basename ${0}) run: '${0} ${ORIG_ARGS}'" { I}
echo "DRY_RUN set..."
echo "Please ignore \"No such file or directory\" from tee..."
else
echo "${TIME_STAMP} Starting $(basename ${0}) run: '${0} ${ORIG_ARGS}'"
echo "${TIME_STAMP} Starting $(basename ${0}) run: '${0} ${ORIG_ARGS}'"
fi
return ${rc}
}
LOGFILE is defined in the wrapper as
{
TMPDIR ="$/tmp"
LOGFILE="${TMPDIR}/${$}/${BASENAME%.*}.log
}
Now when its calling funtion1, funtion2 which basically calls other bash scripts its logging all the output in the file .i.e. { TMPDIR}/${$}/${BASENAME%.*}.log } as well as on the bash terminal.
I wanted that it should only echo what I have written in the wrapper on to the bash terminal and rest should be recorded in the log.
PleaseNote:- the called scripts from wrapper have echo function within but I don’t wanted that there output should be displayed on the terminal
Is it possible to achieve....