Read from Log file in Ksh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Read from Log file in Ksh
# 1  
Old 09-24-2010
Read from Log file in Ksh

I have a log file like..

Code:
 
IMPORT from /dataserver/ftp/bits/mdr/mdr_data_discon.dat OF DEL .....
Number of rows read         = 1376
Number of rows skipped      = 0
Number of rows inserted     = 1374
Number of rows updated      = 0
Number of rows rejected     = 2
Number of rows committed    = 1376
SQL3107W  There is at least one warning message in the message file.
IMPORT from /dataserver/ftp/bits/mdr/mdr_data_discon.dat OF DEL ......
Number of rows read         = 1376
Number of rows skipped      = 0
Number of rows inserted     = 1373
Number of rows updated      = 1
Number of rows rejected     = 2
Number of rows committed    = 1376

There are number of blocks like this in the log file.
I have to get the values of say "Number of rows inserted" or "Number of rows updated" or "Number of rows rejected". from a particular block.
say.. 2nd block.
if i grep for the "Number of rows rejected" it gives all the statements in the log file which is not what i want.i have to get the inserted values from a particular block(by block i mean starting with Number of rows read = to Number of rows committed = ). Please help me how to do it in a ksh.

Thanks in advance.
# 2  
Old 09-24-2010
What have you tried so far? What are you looking for initially? Is /dataserver/ftp/bits/mdr/mdr_data_discon.dat the log file? What are its contents?
# 3  
Old 09-24-2010
Thanks for the reply./dataserver/ftp/bits/mdr/mdr_data_discon.dat is the import statement in the log file.it's not the log file name.data is imported into tables and these are emitted by databse.
Code:
 
Number of rows read         = 1376
Number of rows skipped      = 0
Number of rows inserted     = 1374
Number of rows updated      = 0
Number of rows rejected     = 2
Number of rows committed    = 1376

these are in the log file.
I'm new to scripting and have no idea how to do it.
Appreciate your help.

Thanks

---------- Post updated at 07:24 PM ---------- Previous update was at 06:58 PM ----------

i have to add updated rows or inserted rows from different blocks.

Last edited by ramse8pc; 09-24-2010 at 08:22 PM.. Reason: some more details
# 4  
Old 09-25-2010
Do you need find out insert line from block from IMPORT line to next IMPORT line?
Code:
awk 'BEGIN{RS="IMPORT";FS="\n"}/SQL3107W/ {print $4}' infile
Number of rows inserted     = 1374

# 5  
Old 09-25-2010
hi rdcwayx,
thanks for the reply.i will try as per ur suggestion.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh - Read input from file and output CSV i same row

Hello I have the following output and want the output to look: FROM: GigabitEthernet0/0 is up, line protocol is up 1 input errors, 0 CRC, 0 frame, 1 overrun, 0 ignored 275 output errors, 0 collisions, 3 interface resets GigabitEthernet0/1 is up, line protocol is up 0... (4 Replies)
Discussion started by: JayJay2018
4 Replies

2. Shell Programming and Scripting

Ksh: How to write the log file simultaneously when .sql file executes by UNIX process

Hello Team- we would like to implement an approach which has to write the log file simultaneously when .sql file is executing by Unix process. At present,it is writing the log file once the process is completed. I've tested the current process with the below approaches and none of them... (1 Reply)
Discussion started by: Hima_B
1 Replies

3. Shell Programming and Scripting

Help with ksh-to read ip file & append lines to another file based on pattern match

Hi, I need help with this- input.txt : L B white X Y white A B brown M Y black Read this input file and if 3rd column is "white", then add specific lines to another file insert.txt. If 3rd column is brown, add different set of lines to insert.txt, and so on. For example, the given... (6 Replies)
Discussion started by: prashob123
6 Replies

4. Shell Programming and Scripting

Create Log File in ksh itself

Hi, I want to create a log file for a running ksh , and the log file absolute path I want to give in ksh itself. To elaborate this - Say I have a ksh - timer.ksh and I want to create a log timer_log.log when I run, to trace this. I am aware of the fact that this can be done using redirection... (4 Replies)
Discussion started by: vinay4889
4 Replies

5. Shell Programming and Scripting

Helping with similar "read -t" for KSH file

Hi all, I've trying to apply this command into my .ksh file, but UNIX doesn't accept this option. I need wait a few seconds (maybe 20sec. is very well). Could you please help me? code: #!/bin/ksh .... .... .... read -t 20 continue_run if ]; then; continue_run='N' fi ...... (3 Replies)
Discussion started by: speed_racer
3 Replies

6. Shell Programming and Scripting

read a file line by line in ksh

Hi, In ksh we use 'while read line' statement to read a file line by line. In my input file I have 5 spaces appended at the end of each line. When I use while read line statement it chops off the spaces at the end of each line Inp.txt aaaa<five spaces> bbbb<five spaces> cccc<five spaces> ... (3 Replies)
Discussion started by: chella
3 Replies

7. Shell Programming and Scripting

ksh - read file with leading spaces

Hi, Could someone has any suggestions on this? When read a line from a file, I need to check the first char in the line, it could be a space or any char. But the leading spaces are removed by read. Thanks. (2 Replies)
Discussion started by: momi
2 Replies

8. Shell Programming and Scripting

need help ksh scripting for log file

I have log files that contain data generated every 5 minutes. I want to extract data from the log files to another log file In each 5 minute series <log4j:event logger="VistaMonitor" timestamp="1200688175425" time="Fri Jan 18 15:29:35 EST 2008" Generated twice (I only to get the date... (2 Replies)
Discussion started by: CathyPro
2 Replies

9. Shell Programming and Scripting

Cannot read variables after ssh with rc file (KSH)

Greetings all, I'm currently making use of the $HOME/.ssh/rc file to launch an automated shell script immediately after the user has been verified through ssh. The current problem that I'm facing now is that I am unable to use the "read" command anymore... seems like the "read" statements are... (0 Replies)
Discussion started by: rockysfr
0 Replies

10. Shell Programming and Scripting

Posting to a log file in KSH

Hello, I am writing this script in ksh (consisting of various functions such as -> read_file, write_file, pront_output and initialise) which basically process input files based on the parameters it contains. My task now is to write any error conditions trapped by any of the function above to... (2 Replies)
Discussion started by: sidamin810
2 Replies
Login or Register to Ask a Question