Home » Infrastructure » Unix » Need small modification in shell script
Need small modification in shell script [message #643853] Tue, 20 October 2015 05:38 Go to previous message
praveenk768
Messages: 5
Registered: October 2015
Junior Member
Hi All,
I am new to shell script.
In the below script, I am calling one sql file(test.sql). If this file returns any data then I have to generate this file(test_$RUN_DATE.FCNA). If the sql files returns no data then I dont want to generate this file(test_$RUN_DATE.FCNA).
I tried one approach like: check the size of FCNA files and based on this I am deleting the FCNA file. But, client are not okay with deletion of file.
Is there any to handle this requirement?

#!/bin/bash
# Case 9523 SQL to run daily at 7pm
# spool file is placed in otmtms/staging then the normal ftp script will copy
# it to otmtms/out for pickup and otmtms/acrhive
# Version 1.0 12-28-2012
SQL_FILE=/ftp/otmtms/config/test.sql
#SID=OTM60APL2D
SID=OAPL2P
RUN_DATE=$(date +%Y%m%d%H%M%S)
tempfile=/tmp/.exec_$RUN_DATE
# Set ORACLE_HOME and related variables
ORACLE_HOME=/u01/app/oracle/product/11.2.0; export ORACLE_HOME
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH
NLS_LANG=American_America.UTF8; export NLS_LANG
# Set PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
sqlplus -S /nolog <<EOF
spool /ftp/test_$RUN_DATE.FCNA
whenever sqlerror exit FAILURE
connect SHIPMAXOWNER/shipmaxowner@$SID 
@$SQL_FILE
EOF
#fcna= /ftp/test_$RUN_DATE.FCNA
#if [ -s $fcna ]
#then
# echo "Exception Encountered****Notification sent via maill****".
#else
# rm /ftp/test_$RUN_DATE.FCNA
# echo "deletion success****".
#fi
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Sometimes getting SP2-0734 error message
Next Topic: How to test the firewall rules on SunOS
Goto Forum:
  


Current Time: Fri Mar 29 10:11:26 CDT 2024