how to print out the error mesaage that is around the oraErr

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
flaskvacuum
Posts: 43
Joined: 08 Mar 2013 11:23

how to print out the error mesaage that is around the oraErr

#1 Post by flaskvacuum » 13 Mar 2013 20:15

Code: Select all

findstr "ORA-[0-9]" alert_L1UAT2.log>>%output-file%


i manage to catch all the ORA-ERROR with the code below and it prints out the result as:

Code: Select all

ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []


How can i print out?

Code: Select all

Tue Mar 12 10:47:24 SST 2013



the pattern of my log file is as below:

Code: Select all

Tue Mar 12 10:47:24 SST 2013
Errors in file /opt/ora10g/minic/OCEAN/udump/orl1_ora_27065.trc:
ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: how to print out the error mesaage that is around the or

#2 Post by foxidrive » 14 Mar 2013 00:03

Do you wish to print a paragraph? We need to see more of your log, above and below.
Or are you trying to print just the date associated with one log entry

You can get all date and errors with this, assuming the dates all have SST in them

Code: Select all

findstr "ORA- SST" file.log

flaskvacuum
Posts: 43
Joined: 08 Mar 2013 11:23

Re: how to print out the error mesaage that is around the or

#3 Post by flaskvacuum » 14 Mar 2013 00:31

foxidrive wrote:Do you wish to print a paragraph? We need to see more of your log, above and below.
Or are you trying to print just the date associated with one log entry

You can get all date and errors with this, assuming the dates all have SST in them

Code: Select all

findstr "ORA- SST" file.log


Erm i wanted to catch those ORA-ERROR and also print out the line above it (2 line before the error match) to show the timing .

Please further advice.

i wanted it to be

Tue Mar 12 10:47:24 SST 2013 ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []

the file format is :
Tue Mar 12 14:55:14 SST 2013
Thread 1 advanced to log sequence 162 (LGWR switch)
Current log# 6 seq# 162 mem# 0: /oradata/L1UAT2/redo06a.log
Current log# 6 seq# 162 mem# 1: /oradata/L1UAT2/redo06b.log
Tue Mar 12 15:03:20 SST 2013
Thread 1 advanced to log sequence 163 (LGWR switch)
Current log# 1 seq# 163 mem# 0: /oradata/OCEAN2/redo01a.log
Current log# 1 seq# 163 mem# 1: /oradata/OCAEN2/redo01b.log
Tue Mar 12 15:35:32 SST 2013
Thread 1 advanced to log sequence 164 (LGWR switch)
Current log# 2 seq# 164 mem# 0: /oradata/OCEAN2/redo02a.log
Current log# 2 seq# 164 mem# 1: /oradata/OCEAN2/redo02b.log
Wed Mar 13 07:10:22 SST 2013
Thread 1 advanced to log sequence 165 (LGWR switch)
Current log# 3 seq# 165 mem# 0: /oradata/OCEAN2/redo03a.log
Current log# 3 seq# 165 mem# 1: /oradata/OCEAN2/redo03b.log
Tue Mar 12 10:47:24 SST 2013
Errors in file /opt/ora10g/admin/OCEAN/udump/ocean_ora_27065.trc:
ORA-00600: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: how to print out the error mesaage that is around the or

#4 Post by foxidrive » 14 Mar 2013 00:55

Code: Select all

@echo off
setlocal enabledelayedexpansion
set "filename=file.log"
set "tempfile=output.txt"

for /F "delims=" %%a in ('findstr "ORA- SST" "%filename%"') do (
set "text=%%a"
if "!text:~0,4!"=="ORA-" (
>>"%tempfile%" echo !d8! %%a
)
set d8=%%a
)
pause

flaskvacuum
Posts: 43
Joined: 08 Mar 2013 11:23

Re: how to print out the error mesaage that is around the or

#5 Post by flaskvacuum » 14 Mar 2013 02:15

is there any further advice?

i would like to find the ORA- error then move 2 lines up to grap the time. really appreciate the help.

mfm4aa
Posts: 70
Joined: 13 Feb 2013 14:02
Location: Europe

Re: how to print out the error mesaage that is around the or

#6 Post by mfm4aa » 14 Mar 2013 02:49

Try this (change the name of the input file):

Code: Select all

@echo off &setlocal enabledelayedexpansion
for /f "delims=" %%i in (test.txt) do (
   set "ftime=%%i"
   if "!ftime:SST=!" neq "!ftime!" set "stime=%%i"
   if "!ftime:ORA-=!" neq "!ftime!" echo !stime! !ftime!
)
endlocal

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: how to print out the error mesaage that is around the or

#7 Post by foxidrive » 14 Mar 2013 02:56

flaskvacuum wrote:is there any further advice?

i would like to find the ORA- error then move 2 lines up to grap the time. really appreciate the help.


Firstly, a file is read from the top down. You can't move two lines up without reading the file again..

Secondly, what's wrong with my solution? This is what it provides and is what you asked for.

Tue Mar 11 10:47:24 SST 2013 ORA-00601: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
Tue Mar 12 10:47:24 SST 2013 ORA-00602: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
Tue Mar 13 10:47:24 SST 2013 ORA-00603: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []


Are you lacking a thank you gene?

mfm4aa
Posts: 70
Joined: 13 Feb 2013 14:02
Location: Europe

Re: how to print out the error mesaage that is around the or

#8 Post by mfm4aa » 14 Mar 2013 03:11

The two codes lead to the same result. I don't know, where the problem is.

flaskvacuum
Posts: 43
Joined: 08 Mar 2013 11:23

Re: how to print out the error mesaage that is around the or

#9 Post by flaskvacuum » 14 Mar 2013 03:15

foxidrive wrote:
flaskvacuum wrote:is there any further advice?

i would like to find the ORA- error then move 2 lines up to grap the time. really appreciate the help.


Firstly, a file is read from the top down. You can't move two lines up without reading the file again..

Secondly, what's wrong with my solution? This is what it provides and is what you asked for.

Tue Mar 11 10:47:24 SST 2013 ORA-00601: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
Tue Mar 12 10:47:24 SST 2013 ORA-00602: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []
Tue Mar 13 10:47:24 SST 2013 ORA-00603: internal error code, arguments: [kcblasm_1], [103], [], [], [], [], [], []


Are you lacking a thank you gene?


no no , please don't misunderstand me. I am still thinking is it possible to just read upwards. Yes your coding do help me alot.
Sorry for causing any problem.

Thank you so much.

flaskvacuum
Posts: 43
Joined: 08 Mar 2013 11:23

Re: how to print out the error mesaage that is around the or

#10 Post by flaskvacuum » 14 Mar 2013 03:16

mfm4aa wrote:Try this (change the name of the input file):

Code: Select all

@echo off &setlocal enabledelayedexpansion
for /f "delims=" %%i in (test.txt) do (
   set "ftime=%%i"
   if "!ftime:SST=!" neq "!ftime!" set "stime=%%i"
   if "!ftime:ORA-=!" neq "!ftime!" echo !stime! !ftime!
)
endlocal


thanks for responding. learn that are different ways of getting to what ones want. I learn new coding too. Thanks guys. appreciate you both.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: how to print out the error mesaage that is around the or

#11 Post by foxidrive » 14 Mar 2013 03:49

flaskvacuum wrote:I am still thinking is it possible to just read upwards. Yes your coding do help me alot.


You can only read from random places in a file if you use random read, which is not available in batch files.

Your file requires the 'memorising' of a previous line and using it at the appropriate time.
Batch files *often* rely on the format of the text file to do the job so it's important to see a representative sample of the file.

flaskvacuum
Posts: 43
Joined: 08 Mar 2013 11:23

Re: how to print out the error mesaage that is around the or

#12 Post by flaskvacuum » 02 Apr 2013 03:30

foxidrive,

don't mind can i re-visit your code again by asking you to explain on the code you have written:

Code: Select all

      set tempfile=D:\testScripts\Check_Alert_DB_BKup\tempfile.txt
      for /F "delims=" %%a in ('findstr "ORA- SST" "alert_L1UAT_test.log"') do (
         set "text=%%a"
         if not "!text:ORA-=!"=="!text!" (
         >>"%tempfile%" echo !d8! %%a>>%output%
         )
            set d8=%%a
         )



don't really understand that part on if not "!..... and the d8 thing.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: how to print out the error mesaage that is around the or

#13 Post by foxidrive » 02 Apr 2013 03:52

I'm sure I replied to a post that was more recent than this one, and didn't hear back from you about that.

Did you have this same issue in another thread?

flaskvacuum
Posts: 43
Joined: 08 Mar 2013 11:23

Re: how to print out the error mesaage that is around the or

#14 Post by flaskvacuum » 02 Apr 2013 04:01

foxidrive wrote:I'm sure I replied to a post that was more recent than this one, and didn't hear back from you about that.

Did you have this same issue in another thread?


erm... .didn't want to confuse others further. Just want to stick to this thread. I realise i don't really understand the code you have initiated here.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: how to print out the error mesaage that is around the or

#15 Post by foxidrive » 02 Apr 2013 05:48

What issues does this have when used with your log file?

Code: Select all

@echo off
findstr /v /i /c:"advanced to log sequence" /c:"Current log#" /c:"Errors in file" "file.log" >"file2.log"


It does most of what you asked and provides a fairly simple to follow log with the information you asked for.

The output can be further refined - if you can tell us what you want.
Try it on a large sample of your log file, so you can see any issues and don't have to ask for even further modifications afterward.

Post Reply