The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-06-2009
ali560045's Avatar
ali560045 ali560045 is offline
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 02:26 AM..
  #2 (permalink)  
Old 01-06-2009
Panos1962 Panos1962 is offline
Registered User
  
 

Join Date: Dec 2008
Location: Thessaloniki, GREECE
Posts: 29
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}"
  #3 (permalink)  
Old 01-06-2009
ali560045's Avatar
ali560045 ali560045 is offline
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 03:42 AM..
  #4 (permalink)  
Old 01-06-2009
ali560045's Avatar
ali560045 ali560045 is offline
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 03:59 AM..
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:58 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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