Thank you, Scott
Ideally, some day I'll have time to migrate it to VBS for NT and post it.
egards
--
Juan Lanus
TECNOSOL
McLeod, Scott wrote:
> Im attaching a sample DB2UEXIT program that I used in another life because
> some people have asked me for it recently. This is a simple korn shell
> script that I ran under AIX but I sure runs in HP and other flavours because
> the code is very generic. The code itself simply copies a log file from the
> directory where I store active logs to another directory where I archive
> them to tape. It does have a nice feature of maintaining an audit log of
> everything it does so you can monitor its status.
>
>
>> <<db2uexit.txt>>
>>
>> TTFN and Hold Fast!
>> Scott McLeod of MacLeod
>> Best Buy, Inc.
>> Sr. Database Architect
>> 7750 Flying Cloud Dr.
>> Eden Prairie, MN 55344
>>
>> (612) 324-0031 (voice)
>> (612) 324-0828 (fax)
>>
>> [EMAIL PROTECTED]
>>
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> #!/bin/ksh
>> ################################################################################
>> #
>> # Usage: db2uexit
>> #
>> # Description: This script migrates active log files to the archive logs
>> # directory. It is invoked by DB2 automatically when a log full condition
>> # occurs.
>> #
>> # Parameters: See the IBM manual for information.
>> #
>> ################################################################################
>> ################################################################################
>> # Run the profile of the DB2 subsystem that invokes the exit
>> ################################################################################
>> MYHOME="/db2_6000/`whoami`"
>> .. $MYHOME/.profile > /dev/null 2>&1
>>
>> ################################################################################
>> # Set a path for a log file that contains info on archiving.
>> ################################################################################
>> DIAGPATH="`db2 get dbm cfg | grep DIAGPATH | cut -c60-100`"
>> DIAGLEVEL="`db2 get dbm cfg | grep DIAGLEVEL | cut -c60-90`"
>> AUDIT_LOG=true
>> AUDIT_LOG_FILE="$DIAGPATH/db2uexit.log"
>> AUDIT_LOG_FILE="/db2_6000/db2p/sqllib/db2dump/db2uexit.log"
>>
>> if [ "$AUDIT_LOG" = true ];then
>> echo "***************************************************************" >>
>$AUDIT_LOG_FILE
>> echo "Userexit begins at `date`" >> $AUDIT_LOG_FILE
>> echo "DIAGLEVEL=$DIAGLEVEL,DIAGPATH=$DIAGPATH" >> $AUDIT_LOG_FILE
>> fi
>> #------------------------------------------------------------------------------#
>> #-- Test the number of parms passed and the format of them. --#
>> #------------------------------------------------------------------------------#
>> if [ $# -ne 4 ];then
>> if [ "$AUDIT_LOG" = true ];then
>> echo "Incorrect number of parms passed to Userexit program" >> $AUDIT_LOG_FILE
>> echo "Number of parms passed was $#" >> $AUDIT_LOG_FILE
>> fi
>> exit 20
>> fi
>>
>> if [ "$1" = ARCHIVE ];then
>> continue
>> else
>> if [ "$1" = RETRIEVE ];then
>> continue
>> else
>> if [ "$AUDIT_LOG" = true ];then
>> echo "Unsupported function requested from Userexit program" >>
>$AUDIT_LOG_FILE
>> echo "Function requested was $1" >> $AUDIT_LOG_FILE
>> fi
>> echo "***************************************************************\n" >>
>$AUDIT_LOG_FILE
>> exit 20
>> fi
>> fi
>>
>> #------------------------------------------------------------------------------#
>> #-- ARCHIVE requests will copy file from activelogs to archivelogs
>> #------------------------------------------------------------------------------#
>> if [ "$1" = ARCHIVE ];then
>> #---------------------------------------------------------------------------#
>> #-- Audit the request --#
>> #---------------------------------------------------------------------------#
>> if [ "$AUDIT_LOG" = true ];then
>> echo "`date` DB2UEXIT AUDIT LOG ENTRY" >> $AUDIT_LOG_FILE
>> echo "Request to $1 file $4 from $3" >> $AUDIT_LOG_FILE
>> fi
>> #---------------------------------------------------------------------------#
>> #-- Copy the file to archivelogs --#
>> #---------------------------------------------------------------------------#
>> LCDBNAME="`echo $2 | tr 'A-Z' 'a-z'`"
>> echo "cp $3$4 $MYHOME/archivelogs/$LCDBNAME" >> $AUDIT_LOG_FILE
>> cp $3$4 $MYHOME/archivelogs/$LCDBNAME >> $AUDIT_LOG_FILE 2>&1
>> UNIXRC=$?
>> if [ "$UNIXRC" -ne 0 ];then
>> STANDRC=$STANDRC_28
>> if [ "$AUDIT_LOG" = true ];then
>> echo "cp Command Failed with RC:$UNIXRC" >> $AUDIT_LOG_FILE
>> fi
>> echo "***************************************************************\n" >>
>$AUDIT_LOG_FILE
>> exit 28
>> fi
>> #---------------------------------------------------------------------------#
>> #-- Audit the request --#
>> #---------------------------------------------------------------------------#
>> if [ "$AUDIT_LOG" = true ];then
>> echo "Request to $1 file $4 from $3 was successful" >> $AUDIT_LOG_FILE
>> fi
>> fi
>>
>> #------------------------------------------------------------------------------#
>> #-- RETRIEVE requests will cp a file from archivelogs to activelogs
>> #------------------------------------------------------------------------------#
>> if [ "$1" = RETRIEVE ];then
>> #---------------------------------------------------------------------------#
>> #-- Audit the request --#
>> #---------------------------------------------------------------------------#
>> if [ "$AUDIT_LOG" = true ];then
>> echo "Request to $1 file $4 to $3" >> $AUDIT_LOG_FILE
>> fi
>> #---------------------------------------------------------------------------#
>> #-- Copy the file
>> #---------------------------------------------------------------------------#
>> LCDBNAME="`echo $2 | tr 'A-Z' 'a-z'`"
>> echo "cp $MYHOME/archivelogs/$LCDBNAME/$4 $3" >> $AUDIT_LOG_FILE
>> cp $MYHOME/archivelogs/$LCDBNAME/$4 $3 >> $AUDIT_LOG_FILE 2>&1
>> UNIXRC=$?
>> if [ "$UNIXRC" -ne 0 ];then
>> if [ "$AUDIT_LOG" = true ];then
>> echo "cp Command Failed with RC:$UNIXRC" >> $AUDIT_LOG_FILE
>> echo " " >> $AUDIT_LOG_FILE
>> fi
>> echo "***************************************************************\n" >>
>$AUDIT_LOG_FILE
>> exit 28
>> fi
>> #---------------------------------------------------------------------------#
>> #-- Audit the request --#
>> #---------------------------------------------------------------------------#
>> if [ "$AUDIT_LOG" = true ];then
>> echo "Request to $1 file $4 to $3 was successful" >> $AUDIT_LOG_FILE
>> fi
>> fi
>>
>> if [ "$AUDIT_LOG" = true ];then
>> echo "Userexit ends at `date`" >> $AUDIT_LOG_FILE
>> echo "***************************************************************\n" >>
>$AUDIT_LOG_FILE
>> fi
>> db2uexit.txt
>>
>> Content-Type:
>>
>> text/plain
>> Content-Encoding:
>>
>> quoted-printable
>>
>>
=====
To unsubscribe, send 'unsubscribe' to [EMAIL PROTECTED]
For other info (and scripts), see http://people.mn.mediaone.net/scottrmcleod