Loop script required within an active log file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Loop script required within an active log file
# 1  
Old 01-21-2011
Loop script required within an active log file

I need some help please...

This is the scenario what I am sitting with.

1 - I am kicking of a batch script.
2 - This batch script is writing to an active log file which is also use by other batch scripts.
3 - I need to monitor this active log file and grep for the script name as well as the status of the script as soon as it ends.
4 - There will be other scripts writing to this active log file which will have a status as well when ending.

So, the idea is to have the following:
1 - A script that will view the active log file, which is called from command line: "viewlog"
2- grep for the "script name" and the "status" and the "status code" whithin the same line
3 - Script need to exit with the "status code" that is produced within this active log file.

Here is an example of the active log file lines, the highlighted line is the line with the "script name", "status" and "status code":
1/19/2011 12:07:04 unikixvsam4 :KIX0501I Executing /pinv/invest1/io07210std/src/BBCONVRT.gnt
01/19/2011 12:07:04 unikixvsam4 :KIX0503I Terminating /pinv/invest1/io07210std/src/BBCONVRT.gnt
01/19/2011 12:07:04 unikixtran4 :KIX0314I Batch job BMI_TA_pdpg.ks ended, status = 0
01/19/2011 12:07:03 unikixvsam4 :KIX0503I Terminating /pinv/invest1/io07210std/src/ARPCR1.gnt
01/19/2011 12:07:04 unikixvsam4 :KIX0301I Entering (VER. 8.1.0p8 - 11/13/2007 )
01/19/2011 12:07:04 unikixvsam4 :KIX1001I Connected to database MQSeries
01/19/2011 12:07:04 unikixvsam4 :KIX0501I Executing /pinv/invest1/io07210std/src/BBCONVRT.gnt


Any help will be appreciated...

Thank You
Henk
Henk Trumpie
# 2  
Old 01-21-2011
Something to start:
Code:
#!/usr/bin/ksh

tail -f ${1}|awk  '/'"${2}"'.*ended/{'"exit "'$NF}'

Usage:
Code:
#viewlog logfile scriptName

# 3  
Old 01-24-2011
tail -f

Hi,

Thank you for the reply, but using the tail command, the script does not exit, although the status is already received within the active log file...

I tried using the more command, but because more only take the line that is there at that specific point in time, it also does not work...

Henk
Henk Trumpie
# 4  
Old 01-24-2011
awk does not print, because tail -f does not terminate, so awk clings to its buffers. Unfortunately, buffer control is not standard in awk. When using gawk, you can use fflush("") after a print command, in mawk you can use mawk -W interactive
This User Gave Thanks to Scrutinizer For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help required with a file rename shell script

Hello everyone, Posting here after a long time, been away from unix world lately and it seems I have forgotten my shell scripting completely. I have a requirement where a csv file contains following columns: Full Registration VIN Stock... (14 Replies)
Discussion started by: tayyabq8
14 Replies

2. Homework & Coursework Questions

Simple loop to mail all active users.

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Send a fortune to all active/logged in users 2. Relevant commands, code, scripts, algorithms: So I understand... (8 Replies)
Discussion started by: kjcraig77
8 Replies

3. Shell Programming and Scripting

Required help on a Generic File-watcher script

Hi All, Good morning... I have prepared a shell script which will monitor files in a certain folder and if available, SCP it to a destination path. Now the challenge I'm facing is my script is currently SCP-ing to only a single destination path. Wherever different destination path is in... (1 Reply)
Discussion started by: saps19
1 Replies

4. Shell Programming and Scripting

script to mail monitoring output if required or redirect output to log file

Below script perfectly works, giving below mail output. BUT, I want to make the script mail only if there are any D-Defined/T-Transition/B-Broken State WPARs and also to copy the output generated during monitoring to a temporary log file, which gets cleaned up every week. Need suggestions. ... (4 Replies)
Discussion started by: aix_admin_007
4 Replies

5. Shell Programming and Scripting

How to filter required data from file using bash script?

Hi All , I have one file like below , Owner name = abu2-kxy-m29.hegen.app Item_id = AX1981, special_id = *NULL*, version = 1 Created = 09/01/2010 12:56:56 (1283389016) Enddate = 03/31/2011 00:00:00 (1301554800) From the above file I need to get the output in the below format ,i need... (3 Replies)
Discussion started by: gnanasekar_beem
3 Replies

6. Shell Programming and Scripting

Getting required fields from a test file in required fromat in unix

My data is something like shown below. date1 date2 aaa bbbb ccccc date3 date4 dddd eeeeeee ffffffffff ggggg hh I want the output like this date1date2 aaa eeeeee I serached in the forum but didn't find the exact matching solution. Please help. (7 Replies)
Discussion started by: rdhanek
7 Replies

7. Shell Programming and Scripting

grep active log file

Hi Gurus, I am facing a problem with grepping a set of data in active log file which are the info not in uniform, below is the sample data information. I am trying to grep value. Connect_PM Connect to APPS gateway failed ERROR connection to host anyserver.com, service 6600 timed out ... (4 Replies)
Discussion started by: anakiar
4 Replies

8. Shell Programming and Scripting

Script to archive log files:Urgent Help required

I have no prior knowledge of Unix shell scripting,but my requriment demands to wrie a script that do fallowing things. 1.Delete older than one year log files 2.Moves files in to the directories as YYYYMM wise. 3.If files in $LOGDIR older than n=2 months tar and move them to $ARCHIVEDIR... (5 Replies)
Discussion started by: vamsx
5 Replies

9. Shell Programming and Scripting

awk script required for finding records in 1 file with corresponding another file.

Hi, I have a .txt file (uniqfields.txt) with 3 fields separated by " | " (pipe symbol). This file contains unique values with respect to all these 3 fields taken together. There are about 40,000 SORTED records (rows) in this file. Sample records are given below. 1TVAO|OVEPT|VO... (2 Replies)
Discussion started by: RRVARMA
2 Replies

10. Shell Programming and Scripting

Outputting formatted Result log file from old 30000 lines result log<help required>

Well I have a 3000 lines result log file that contains all the machine data when it does the testing... It has 3 different section that i am intrsted in 1) starting with "20071126 11:11:11 Machine Header 1" 1000 lines... "End machine header 1" 2) starting with "20071126 12:12:12 Machine... (5 Replies)
Discussion started by: vikas.iet
5 Replies
Login or Register to Ask a Question