[HPADM] Log script output to both stdout and to a log file

From: Abramson, Stuart (SAbramson@Wabtec.com)
Date: Thu Jan 22 2004 - 14:47:11 EST


Hpux-admins:

We have set some scripts up to log all of their output to log files, because
we lost some log files in the past:

        LOGDIR=/var/opt/timefinder/logs
        SCRIPT=$(basename $0 .ksh)
        BCVSET=$1
        LOGDATE=$(date +%m%d%y-%H%M)
        LOG=${LOGDIR}/${SCRIPT}_${BCVSET}.${LOGDATE}.log
        exec 2>${LOG}
        exec >&2
        find ${LOGDIR} -name "${SCRIPT}*.log" -mtime +7 -exec rm {} \;

But I want to actually see the script output when I run it from my desk:

        ksh -x script.ksh

AND capture the script log in the log file.

How do I modify the script to do that? Can I use the "tee" command with the
above "exec" commands somehow.. .

        Stuart

Stuart Abramson | WABTEC Corp. | Wilmerding, PA
Off: 412/825-1434 | Cell: 412/417-1567 | email: sabramson@wabtec.com

***** CONFIDENTIALITY NOTE *****
The content contained in this e-mail transmission is legally privileged and confidential information intended only for the use of the individual or entity named herein. If the reader of this transmission is not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this transmission is strictly prohibited.

--
             ---> Please post QUESTIONS and SUMMARIES only!! <---
        To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl
       Name: hpux-admin@dutchworks.nl     Owner: owner-hpux-admin@dutchworks.nl
 
 Archives:  ftp.dutchworks.nl:/pub/digests/hpux-admin       (FTP, browse only)
            http://www.dutchworks.nl/htbin/hpsysadmin   (Web, browse & search)


This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 11:02:38 EDT