« Setting password for Oracle listener in the script | Home | Find actual device numbers in Sybase »
Redirect script output to the log
If the whole output of the complex script should be redirected to the log, the following trick could be used.
if [ "$1" != "-log" ] ; then
$0 -log "$@" 2>&1 | tee the_log_file.$$.log
echo "The log file for the current session: the_log_file.$$.log"
exit 0
fi
shift # remove "-log" parameter
$0 -log "$@" 2>&1 | tee the_log_file.$$.log
echo "The log file for the current session: the_log_file.$$.log"
exit 0
fi
shift # remove "-log" parameter
... script body ...
Topics: Unix Shell, log, output | Submitter: checkthis
Comments
You must be logged in to post a comment.