Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Unix script

Re: Unix script

From: <Brian_P_MacLean_at_eFunds.Com>
Date: Tue, 16 Apr 2002 09:03:52 -0800
Message-ID: <F001.004458D5.20020416090352@fatcity.com>

Still room for improvement but enough changes to keep you busy for awhile. Please note that I changed the script to use ksh shell (required by several of the commands I added) and the "exec" command that will redirect all script text output to a common file so that you don't have to redeclare the output file with each "tail" and "echo" command. Have fun......

#!/bin/ksh
JOB_LOG=/d31/appl/konto/log/laddabilbo.txt exec 1>${JOB_LOG} 2>&1
. /usr/bin/orasetup.sh
. /d31/appl/konto/bat/movefiles.sh
STATUS=0
echo "

###########################################################################"
echo "#Starting ${0##*/} at $(date)"
echo "#"
sqlldr userid=konto/icakort control=/d31/appl/konto/bat/ehbgrupp.ctl log=/d31/appl/konto/log/ehbgrupp.log
STATUS=$((${STATUS} + ${?}))
sqlldr userid=konto/icakort control=/d31/appl/konto/bat/kampanj.ctl log=/d31/appl/konto/log/kampanj.log
STATUS=$((${STATUS} + ${?}))
sqlldr userid=konto/icakort control=/d31/appl/konto/bat/mxurval.ctl log=/d31/appl/konto/log/mxurval.log
STATUS=$((${STATUS} + ${?}))
sqlldr userid=konto/icakort control=/d31/appl/konto/bat/load_arg.ctl log=/d31/appl/konto/log/load_arg.log
STATUS=$((${STATUS} + ${?}))
sqlldr userid=konto/icakort control=/d31/appl/konto/bat/laddabsg.ctl log=/d31/appl/konto/log/laddabsg.log
STATUS=$((${STATUS} + ${?}))
sqlplus -s konto/icakort << !
  whenever sqlerror exit 1
  set heading off
  set verify off
  set feedback off
  set termout off
  set pages 0
  begin
  konto.fillbilbotables.anrop;
  END;
/

  EXIT
!
STATUS=$((${STATUS} + ${?}))
echo "------------------------------------------------------"
echo "ehbgrupp status "
tail -11 /d31/appl/konto/log/ehbgrupp.log
echo "------------------------------------------------------"
echo "------------------------------------------------------"
echo "kampanj status "
tail -11 /d31/appl/konto/log/kampanj.log
echo "------------------------------------------------------"
echo "------------------------------------------------------"
echo "mxurval status "
tail -11 /d31/appl/konto/log/mxurval.log
echo "------------------------------------------------------"
echo "------------------------------------------------------"
echo "load_arg status "
tail -11 /d31/appl/konto/log/load_arg.log
echo "------------------------------------------------------"
echo "------------------------------------------------------"
echo "laddabsg status "
tail -11 /d31/appl/konto/log/laddabsg.log
echo "------------------------------------------------------"
echo "Jobb klart! :\c"
date

v_error_sum=0
egrep "Total logical records skipped|Total logical records rejected|Total logical records discarded" \

    /d31/appl/konto/log/ehbgrupp.log /d31/appl/konto/log/kampanj.log

/d31/appl/konto/log/mxurval.log \

    /d31/appl/konto/log/load_arg.log /d31/appl/konto/log/laddabsg.log |
  cut -d":" -f2 | while read v_error_number do
  v_error_sum=$((${v_error_sum} + ${v_error_number})) done
if [ ${v_error_sum} -gt 0 ]
then
  STATUS=$((${STATUS} + 1))
fi

echo "#"
echo "#Job run time was: $((${SECONDS} / 3600)) hours, $(((${SECONDS} % 3600) / 60)) minutes, $((${SECONDS} % 60)) seconds"

echo "#"
echo "#Ending ${0##*/} at $(date) with an exit status of ${1}"
echo "
###########################################################################"

if [ ${STATUS} -gt 0 ]
then
  cat /d31/appl/konto/log/laddabilbo.txt \     | mailx -s "Konto - Statusrapport" roland.skoldblom_at_ica.se mats.wieweg_at_ica.se jesper.danielsson_at_ica.se fi

#
# END-OF-SCRIPT
###########################################################################





Brian P. MacLean
Oracle DBA, OCP8i

                                                                                                                    
                    Roland.Skoldbl                                                                                  
                    om_at_ica.se            To:     Multiple recipients of list ORACLE-L <ORACLE-L_at_fatcity.com>        
                    Sent by:             cc:                                                                        
                    root_at_fatcity.c       Subject:     Unix script                                                   
                    om                                                                                              
                                                                                                                    
                                                                                                                    
                    04/15/02 11:43                                                                                  
                    PM                                                                                              
                    Please respond                                                                                  
                    to ORACLE-L                                                                                     
                                                                                                                    
                                                                                                                    




Hallo,

I have this unix script, please tell me how to change it so it also does the following:
(See attached file: laddabilbo.sh)

counts the time between start time and end time of the process(I mean time difference between Jobb startat(Job started) and Job Klart(Job Finished).

IThis log file is also sent by mail to people. I would like this log file only to be sent if there is anything wrong with the script(for instance if the database is down) So if the script goes fine, then no email will be sent.

The log file looks like this:

Jobb startat :Sun Apr 14 18:06:23 MEST 2002



ehbgrupp status
Total logical records skipped:          0
Total logical records read:           400
Total logical records rejected:         0
Total logical records discarded:        0

Run began on Sun Apr 14 18:06:23 2002
Run ended on Sun Apr 14 18:11:51 2002

Elapsed time was:     00:05:28.15
CPU time was:         00:00:00.07     (Ma
------------------------------------------------------
------------------------------------------------------
kampanj status
Total logical records skipped:          0
Total logical records read:            13
Total logical records rejected:         0
Total logical records discarded:        0

Run began on Sun Apr 14 18:11:51 2002
Run ended on Sun Apr 14 18:12:44 2002

Elapsed time was:     00:00:52.52
CPU time was:         00:00:00.04     (Ma
------------------------------------------------------
------------------------------------------------------
mxurval status
Total logical records skipped:          0
Total logical records read:          4829
Total logical records rejected:         0
Total logical records discarded:        0

Run began on Sun Apr 14 18:12:44 2002
Run ended on Sun Apr 14 18:12:50 2002

Elapsed time was:     00:00:05.90
CPU time was:         00:00:00.18     (Ma
------------------------------------------------------
------------------------------------------------------
load_arg status
Total logical records skipped:          0
Total logical records read:        151613
Total logical records rejected:         0
Total logical records discarded:        0

Run began on Sun Apr 14 18:12:50 2002
Run ended on Sun Apr 14 18:28:11 2002

Elapsed time was:     00:15:20.92
CPU time was:         00:00:25.07     (Ma
------------------------------------------------------
------------------------------------------------------
laddabsg status
Total logical records skipped:          0
Total logical records read:         92326
Total logical records rejected:         0
Total logical records discarded:        0

Run began on Sun Apr 14 18:28:11 2002
Run ended on Sun Apr 14 18:40:15 2002

Elapsed time was:     00:12:03.95
CPU time was:         00:00:32.17     (Ma
------------------------------------------------------
Jobb klart! :Sun Apr 14 18:49:23 MEST 2002

I would really appreciate help.

Thanks in advance

Roland

(See attached file: laddabilbo.sh)


-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: 
  INET: Brian_P_MacLean_at_eFunds.Com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Received on Tue Apr 16 2002 - 12:03:52 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US