05-07-2008
UNIX script Validation
Hi,
I have a UNIX script which has two parts:
1. It connects to a database and refreshes a materialized view
2. It then connects to another database and inserts refresh statistics to a table
The script works, but I'm not too good at UNIX validation. Currently, if the first part of the job fails - the entire script bombs out.
What I would like it to do is, if the first part fails, then continue with the second part of the script, but still record an overall failure in the log file.
Below is the code at present. I think I need some conditionsal 'flags' but do not know where to begin. Please can someone help? See below:
. /usr/opt/oracle/cron/set_oraenv
. ${SCRIPT_DIR}/set_connect_params
export TOP_SCHEMA=${TOP_LOG}
export WHSE_SCHEMA=${VIW_LOG}
LOG_DIR=${SCRIPT_DIR}/logs
SCHED_DATE=`date "+%y%m%d"`
JOBSET_LOG=${LOG_DIR}/RUN_ROT_TOP_OCRS_MV_LOG_"$ENV"_$SCHED_DATE
export JOBSET_LOG
export LOG_DIR
echo "`date`: Refresh of ROT_TOP_OCRS_MV started" >> ${JOBSET_LOG}
#################################################################################
#
# Run the refresh of the ROT_TOP_OCRS_MV materialized view and then gather stats.
# Finally, insert an entry to COM_TABLE_LOAD_HIST to log the MV refresh.
#
#################################################################################
sqlplus -s ${TOP_LOG}/${TOP_PW}@${TOP_SID} <<END1>> ${JOBSET_LOG}
whenever sqlerror exit 2
whenever oserror exit 3
set heading off
set serveroutput on
select 'User ID: '||user||CHR(13)||CHR(10)||'Connected to: '||rtrim(global_name,'.US.ORACLE.COM.ATOSORIGIN') from dual,global_name;
select to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS') from dual;
execute DBMS_OUTPUT.PUT_LINE('*** Now running the weekly ROT_TOP_OCRS_MV materialized view refresh ***');
execute DBMS_MVIEW.REFRESH('${TOP_SCHEMA}.ROT_TOP_OCRS_MV');
select to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS') from dual;
execute DBMS_OUTPUT.PUT_LINE('*** Now gathering statistics ***');
exec DBMS_STATS.GATHER_TABLE_STATS(ownname => '${TOP_SCHEMA}',tabname => 'ROT_TOP_OCRS_MV',cascade => TRUE);
select to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS') from dual;
exit
END1
if [ $? -ne 0 ]
then
echo "`date`: Refresh of ROT_TOP_OCRS_MV failed" >> ${JOBSET_LOG}
exit 3
else
echo "`date`: Refresh of ROT_TOP_OCRS_MV completed successfully" >> ${JOBSET_LOG}
fi
sqlplus -s ${VIW_LOG}/${VIW_PW} <<END1>> ${JOBSET_LOG}
whenever sqlerror exit 2
whenever oserror exit 3
set heading off
set serveroutput on
select 'User ID: '||user||CHR(13)||CHR(10)||'Connected to: '||rtrim(global_name,'.US.ORACLE.COM.ATOSORIGIN') from dual,global_name;
select to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS') from dual;
execute DBMS_OUTPUT.PUT_LINE('*** Now inserting record stats to COM_TABLE_LOAD_HIST ***');
insert into COM_TABLE_LOAD_HIST
select 'ROT_TOP_OCRS_MV',count(*),null,null,null,null,sysdate,'ROT_TOP_OCRS_MV last refreshed on '||to_char(sysdate,'DD-MON-RR') from ROT_TOP_OCRS_MV;
commit;
select to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS') from dual;
exit
END1
if [ $? -ne 0 ]
then
echo "`date`: Refresh of ROT_TOP_OCRS_MV failed" >> ${JOBSET_LOG}
exit 3
else
echo "`date`: Refresh of ROT_TOP_OCRS_MV completed successfully" >> ${JOBSET_LOG}
exit 0
fi
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am very new to scripting in UNIX and in need of help. I am creating a program that will check a file that has a target time in the form of HH:MM:SS before another program can begin executing. The file with the target time will only have that target time in it and nothing else.
Is there any way... (1 Reply)
Discussion started by: mosammey
1 Replies
2. UNIX for Dummies Questions & Answers
I am very new to scripting in UNIX and in need of help. I am creating a program that will check a file that has a target time in the form of HH:MM:SS before another program can begin executing. The file with the target time will only have that target time in it and nothing else.
Is there any... (4 Replies)
Discussion started by: mosammey
4 Replies
3. UNIX for Dummies Questions & Answers
is there any way to check null data against some of the column in file
My file have such structure
1,,4,SUMISHO ,SMG110880 ,1,12,SUMISHO CAPITAL MANAGEMENT (SINGAPORE) PTE LTD ,ACCT01,20080531,2008,5,30,20080630,1,1,TXGRP ,CGST ,1,74,5.18,74,0,5.18... (2 Replies)
Discussion started by: u263066
2 Replies
4. UNIX for Dummies Questions & Answers
Hi All,
I got a file with 3 fields delimited by hyphen "-". I have to validate & cleanse the data before i begine the processing
Requirements
1. No record should contain more than 2 delimiters
2. No record should even contain less than 2 delimiters
3. Any records that matches rule 1 &... (1 Reply)
Discussion started by: minnuverma
1 Replies
5. UNIX for Advanced & Expert Users
Hi All,
I got a file with 3 fields delimited by hyphen "-". I have to validate & cleanse the data before i begine the processing
Requirements
1. No record should contain more than 2 delimiters
2. No record should even contain less than 2 delimiters
3. Any records that matches rule 1 &... (3 Replies)
Discussion started by: minnuverma
3 Replies
6. Shell Programming and Scripting
Hi All,
I got a file with 3 fields delimited by hyphen "-". I have to validate & cleanse the data before i begine the processing
Requirements
1. No record should contain more than 2 delimiters
2. No record should even contain less than 2 delimiters
3. Any records that matches rule 1 &... (8 Replies)
Discussion started by: minnuverma
8 Replies
7. Shell Programming and Scripting
I have a script which is take date as parameter
sh abc.sh <2010-02-01>
#!/sh/bin
my_date=$1
#Here i want to two diffrent dates
## 3 Days before
##date14query=$mydate - 4 (it will be 2010-01-28)
##date24query=$mydate +4 (it will be 2010-01-05)
#Please Help (3 Replies)
Discussion started by: pritish.sas
3 Replies
8. UNIX for Dummies Questions & Answers
Dears,
I am working on a batch that processes file with name containing date prefix eg., 20101222_file.dat.
The logic is to process files in order. Eg., 20101225 must be processed only after 20101222.
Ok first glance it looked simple, it use a variable to check this date value as number and... (2 Replies)
Discussion started by: naraink
2 Replies
9. Shell Programming and Scripting
Hi All,
I am completely new to Unix Shell Scripting.
I m validating(Basic File Validation) an .HHT file in TIBCO.
After that i need to do Data Validation through UNIX Shell scripting.
Rules in DataValidation:
1.) Need to Check Every field wheather it is a Char or Number?(Fields are... (1 Reply)
Discussion started by: Chaitanya K
1 Replies
10. Shell Programming and Scripting
Please help me to validate PAN card using unix
---------- Post updated at 03:06 AM ---------- Previous update was at 02:21 AM ----------
1) The first three letters are sequence of alphabets from AAA to zzz
2) The fourth character informs about the type of holder of the Card. Each assesse... (1 Reply)
Discussion started by: suryanarayana
1 Replies
LEARN ABOUT CENTOS
installsieve
INSTALLSIEVE(1) General Commands Manual INSTALLSIEVE(1)
*
NAME
installsieve - user utility for managing sieve scripts
SYNOPSIS
installsieve
DESCRIPTION
installsieve is a utility that allows users to manage their sieve scripts kept on the server.
OPTIONS
-v <name> View script with the given name. The script if retrieved sucessfully is output to standard output.
-l List all of the scripts currently on the server. If one of the scripts is active a arrow is printed indicating that it is the active
script.
-p <port> Port to connect to. If left off this defaults to "sieve" as defined in /etc/services.
-i <file> Install a file onto the server. If a script with the same name already exists on the server it is overwritten. Upon sucessfully
putting the script on the server the script is set active. If <file> has the extension .script it is chopped when put on the server since
sieve names may not contain a '.'.
-a <name> Set <name> as the active script. The list of available names can be obtained from the '-l' option..
-d <name> Delete the sieve script on the server with <name>.
-m <mechanism> Force installsieve to use <mechanism> for authentication. If not specified the strongest authentication mechanism is chosen.
-g <name> Get the sieve script with <name> and save it to disk with a ".script" extension. If a file with that name already exists it is
overwritten.
-u <user> Userid/Authname to use for authentication; by default, the current user.
CMU
Project Cyrus INSTALLSIEVE(1)