Sh Prgram to capture Log message.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sh Prgram to capture Log message.
# 1  
Old 12-30-2005
Sh Prgram to capture Log message.

Hi All,

I have a log file which consists of log messages as follows ->

GLOBALCALLID_CLUSTERID_B NEXT * , O(") CHARACTER
JOINONBEHALFOF NEXT * , O(") CHARACTER

Record 1: Rejected - Error on table IFA_MMV_CDR, column CDRRECORDTYPE.
ORA-01722: invalid number

Record 1811: Rejected - Error on table IFA_MMV_CDR.
ORA-01400: cannot insert NULL into ("VOIP3"."IFA_MMV_CDR"."ORIGIPPORT")

Record 1833: Rejected - Error on table IFA_MMV_CDR.
ORA-01400: cannot insert NULL into ("VOIP3"."IFA_MMV_CDR"."ORIGIPPORT")


Table IFA_MMV_CDR:
1813 Rows successfully loaded.
3 Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.


I want to know how can I use this data to get the total number of records failed and get the reasons for each record failed as stated with the record number in some shell variables in a shell script.


Thanks,
Rahul.
# 2  
Old 12-30-2005
Hi Rahul,
Hmm, lets c if I get you correct.

1. Collect all the error messages and reason as a single line in a new file

grep -e "^Record" -e "ORA-" samp.txt | sed 'N;s/\n/ /g' > samp1.txt

2. Number of erroneous records
wc -l samp1.txt

3. get the record number and reason of failure for this record in shell variables
cat samp1.txt|while read i
do
recno=`echo "$i"|awk '{print $2}'
reason=`echo "$i"|nawk -F "ORA-" '{print $2}'
#Process $recno and $reason as you want.
done


Hope this helps

Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SFTP Scripting and Log capture

Hi All, Need help in below query, appreciate your help. We are changing a FTP process to SFTP ( passwordless SSH ) I had few queries on how to log the transfer details into a log file. ----------------------------------------------------- PUTLOGFILE= /xxx/ftp_log.log FAILPUTLOGFILE=... (0 Replies)
Discussion started by: aadarshtripathi
0 Replies

2. Shell Programming and Scripting

How can view log messages between two time frame from /var/log/message or any type of log files

How can view log messages between two time frame from /var/log/message or any type of log files. when logfiles are very big and especially many messages with in few minutes, I would like to display log messages between 5 minute interval. Could you pls give me the command? (1 Reply)
Discussion started by: johnveslin
1 Replies

3. Shell Programming and Scripting

Capture all error message in Log file and send the Log file by email

Hi I have a requirement to write a script to capture all errors in a Logfile and send the file in email. If there is any error occurred the subject of email will be ERROR , If there are no error occurred the subject of email will be SUCCESS. So I created a Log file and put the Appropriate... (2 Replies)
Discussion started by: dgmm
2 Replies

4. Shell Programming and Scripting

Log Capture for Background Process

Hi , I am running a backgorund process called hello.sh ./hello & Now i need to capture the log file as it produces the output . i am not able to use " >> " nor " tee " to capture the output file / log file . Please let me know how can i do it ? Regards, Deepak Konnur (3 Replies)
Discussion started by: dskonnur
3 Replies

5. Shell Programming and Scripting

capture last run log using dsjob

Hi All, Could you please let me know how to capture the WARNING or FATAL errors for the last run log using dsjob -logsum in Korn Unix Shell. Thanks in Advance, (0 Replies)
Discussion started by: HemaV
0 Replies

6. Shell Programming and Scripting

How to capture output to log file

Hi I have a script that will run multiple unix & sql commands. I want to see the output as well as capture it to a log file for further analysis. Is there an easy way to do that instead of adding "tee -a logfile" on everyline or even on the execute line (i.e. script | tee -s logfile). Thanks (1 Reply)
Discussion started by: nimo
1 Replies

7. Shell Programming and Scripting

[Perl] Capture system call error message.

Hi, I googled a bit, but could not find the answer to my problem. But I am sure it is a common issue. I have this code: #!/bin/perl -w #-d use strict; sub remsh_test() { my $host = $_; printf "\n----\n\n"; printf "remsh to $host with system call\n"; my $result = system... (3 Replies)
Discussion started by: ejdv
3 Replies

8. Shell Programming and Scripting

How to capture actual error message when a command fails to execute

I want to capture actual error message in case the commands I use in my shell script fails. For eg: ls -l abc.txt 2>>errorlog.txt In this case I understand the error message is written to the errorlog.txt and I assume its bacause the return code from the command ls -l abc might return 2 if... (3 Replies)
Discussion started by: prathima
3 Replies

9. Shell Programming and Scripting

How to capture status code and echo a message

Im trying to execute application and its return code is below IF Status code=o echo "........" else Staus Code =-2 DJRE then echo "......" Can any one help me how to handle the status code and echo some message. (12 Replies)
Discussion started by: laknar
12 Replies

10. Shell Programming and Scripting

capture nohup log file

Hi, I am running my script using nohup, but I am not able to capture the log file for that process could naybody please help... Here is what I am doing.... nohup ./script & 1>/home/user1/log.txt but I am not able to capture the log.....Is there anyother way I can capture the log... (2 Replies)
Discussion started by: mgirinath
2 Replies
Login or Register to Ask a Question