The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
why shell script fails? tahir23 Shell Programming and Scripting 4 08-25-2008 09:46 AM
why script fails sometime? tahir23 UNIX for Advanced & Expert Users 10 08-21-2008 06:04 PM
why shell script fails tahir23 Shell Programming and Scripting 4 08-21-2008 10:37 AM
file <filename> fails kingskar UNIX for Advanced & Expert Users 2 08-14-2006 09:07 AM
Script fails JStone Shell Programming and Scripting 8 08-10-2006 12:00 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-06-2009
ali560045's Avatar
Registered User
 

Join Date: Oct 2007
Posts: 328
log file when the script fails !

i have a script that will retrive some info from database. The script is working fine but i have to add new feature in it when the script fails or retrive null result it should reflect in the log file.

below the script AMR_Inactive.sh
Code:
while read i
do

connect1=`sqlplus -silent amit/qwerty@edna.world <<END
set pagesize 0 feedback off verify off heading off echo off
SELECT meter.X_UDC_ASSET_ID
 FROM
    SIEBEL.S_ASSET Meter,
    SIEBEL.S_ASSET SDP,
    SIEBEL.s_asset_rel ARSM,
        SIEBEL.S_ADDR_PER Premise,
        SIEBEL.S_ASSET Route,
        SIEBEL.s_asset_rel ARSR
 WHERE
        ARSM.par_asset_id = SDP.row_id AND
        ARSM.asset_id = Meter.row_id AND
        ARSM.relation_type_cd = 'SDP-METER' AND
        ARSM.x_rel_status = 'Active' AND
     SDP.PER_ADDR_ID = Premise.row_id AND
        ARSR.par_asset_id = Route.row_id AND
        ARSR.asset_id = SDP.row_id AND
        ARSR.relation_type_cd = 'ROUTE-SDP' AND
        ARSR.x_rel_status = 'Active' AND
                Premise.X_CLIENT_PRMSE_ID = '$i';
exit;
END`
echo "Completed for $i" 
echo "$connect1" 
done < TNS_AMRI_INACTIVE.txt
contents of TNS_AMRI_INACTIVE.txt
Quote:
0002034694
if suppose for this data the script returns null result i should get the info "No rows returned" in my log file.i m runnig the script using crontab

AMR_Inactive.sh > AMR_Inactive.log 2>&1

Last edited by ali560045; 01-06-2009 at 01:26 AM..
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-06-2009
Registered User
 

Join Date: Dec 2008
Location: Thessaloniki, GREECE
Posts: 26
The only thing you have to do is check the ${connect1} value before printing it:
Code:
if [ -n "${connect1}" ]; then
    echo "${connect1}"
else
    echo "No rows returned"
fi
instead of just:

Code:
echo "${connect1}"
Reply With Quote
  #3 (permalink)  
Old 01-06-2009
ali560045's Avatar
Registered User
 

Join Date: Oct 2007
Posts: 328
Thanks . But what if suppose after select statement i m updating using that value and if update fails how to get that in log file.

Basically how to show in the log file that the given SQL query has really worked successfully or not .......

Last edited by ali560045; 01-06-2009 at 02:42 AM..
Reply With Quote
  #4 (permalink)  
Old 01-06-2009
ali560045's Avatar
Registered User
 

Join Date: Oct 2007
Posts: 328
i have now modified the code instead of select i m now doing update . i have use the spool concept here.

But still i m not getting any info like "0 rows Updated" in the spool file. How to get that info in spool file

below the code using update
Code:
#!/bin/ksh

. $HOME/conf/systemProperties/EnvSetup.properties


sqlplus -silent amit/qwerty@edna.world <<END
set pagesize 0 feedback off verify off heading off

spool Script_Fails.log 

UPDATE SIEBEL.S_ASSET_XM SDPX 
SET SDPX.ATTRIB_03   = 'Inactive', 
SDPX.LAST_UPD_BY = '1-42V', 
SDPX.LAST_UPD    = SYSDATE, 
SDPX.ATTRIB_04   = 'SQQ3' 
 WHERE SDPX.PAR_ROW_ID  IN ('090845086LG')
   AND SDPX.ATTRIB_01   = 'AMR Ready' 
   AND SDPX.ATTRIB_03   = 'Active';

commit;
exit;
END
when RUN this update statement in my database it is showing "no rows Update". This same information i want in the spool file.How to get that ?

Thanks in advance

Last edited by ali560045; 01-06-2009 at 02:59 AM..
Reply With Quote
Google The UNIX and Linux Forums
Reply

Bookmarks

Tags
None

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:




All times are GMT -4. The time now is 12:04 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66