Sponsored Content
Top Forums Shell Programming and Scripting Seeking for help in writing shell Post 302278150 by anakiar on Monday 19th of January 2009 01:14:42 PM
Old 01-19-2009
Data Seeking for help in writing shell

Hi All,

I got a problem and stuck to filter a log file, called it as "sample.log". This "sample.log" file is being generated by "script A". The "sample.log" look like below:

Code:
:FORMATDATE_FORMATTIME:CmdArg->:SomeDoce:SomeFormatDocument:
:FORMATDATE_FORMATTIME:imprtcp succeeded.
:FORMATDATE_FORMATTIME:imprttyp completed.
:FORMATDATE_FORMATTIME:fdcode2 failed
::
::...........................
:FORMATDATE_FORMATTIME:CmdArg->:SomeDoce:SomeFormatDocument:
:FORMATDATE_FORMATTIME:imprtcp succeeded.
:FORMATDATE_FORMATTIME:imprttyp completed.
:FORMATDATE_FORMATTIME:DocCode = yadayada(00)
:FORMATDATE_FORMATTIME:Document type is yada.
:FORMATDATE_FORMATTIME:Document not paginated or not text.
:FORMATDATE_FORMATTIME:yada yada succeeded.
:FORMATDATE_FORMATTIME:yada yada succeeded, size=1248.
:FORMATDATE_FORMATTIME:nimport succeeded.

What i try to do is,Since the "sample.log" is actively growing up. i need to

1) Grep the the value failed and also all the required data. i should get like below:-
Code:
:FORMATDATE_FORMATTIME:CmdArg->:SomeDoce:SomeFormatDocument:
:FORMATDATE_FORMATTIME:imprtcp succeeded.
:FORMATDATE_FORMATTIME:imprttyp completed.
 :FORMATDATE_FORMATTIME:fdcode2 failed

2) and email it to the me as an alert.

P/S this script will run in cron to actively monitor the "failed" data.
May be somebody cay help me on figure it out how can i do this.

Currently what i have is:

1) tail -f sample.log | grep failed >> samplelog.failed
## but i stuck at here because tail -f cannot output to other files, i tried but failed, no output has been generate.

2)
test=$(cat samplelog.failed | cut -d: -f-2)
cat sample.log | grep $test: | /usr/bin/mailx -s "Subject" to@somebody


Thanks for your helping in here.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Writing a shell Script

How to write a shell script file to read 5 numbers using a while loop. Finding the average, maximum and minumum for the numbers. Any help would be great. (1 Reply)
Discussion started by: Chin
1 Replies

2. Shell Programming and Scripting

Need help for writing shell script

Hello ALL, I am fresher in Unix . i need help to write small shell script . Please help me unix guru. I am developing the internal site in my office . the data files are generated in one directory everyday . I have to write shell script to sort those files and put it is internal site . ... (3 Replies)
Discussion started by: deepa20
3 Replies

3. AIX

Difference between writing Unix Shell script and AIX Shell Scripts

Hi, Please give me the detailed Differences between writing Unix Shell script and AIX Shell Scripts. Thanks in advance..... (0 Replies)
Discussion started by: haroonec
0 Replies

4. Shell Programming and Scripting

Writing shell script

Hi, I am a new for shell script. i need to write script using the following commands cd /usres/test # create directory mkdir temp+DATE( i need to append date ) #moving files from one directory to this directory(we need to check total files in source and taget) cd /users/sample ... (2 Replies)
Discussion started by: bmkreddy
2 Replies

5. Shell Programming and Scripting

seeking help with shell script

I am trying to update a script which I had created to monitor tablespace usage. Originally the sql spooled out to a text file anything with more than 75% used. I have been asked to change this. Now the sql must spool out all tablespaces. The script I have to write should scan the file for... (4 Replies)
Discussion started by: Niadh
4 Replies

6. Shell Programming and Scripting

Writing a shell script

Hi I have two files a.log and b.log . i need to append a.log and b.log so that at the end of first line in a.log i need the append the data of first line from b.log and end of the second line in a.log i need to append the data of second line from b.log and so on up to the end of the file can... (3 Replies)
Discussion started by: lalu
3 Replies

7. Shell Programming and Scripting

Two problems when I am writing my own shell

Hi, guys: I am writing my own shell using c. I meet with two problems. First, when I use tcsetpgrp system call to move a background job to foreground, when this job finishes, my shell program also exit. What is the problem for that? Second, when I use signal , if the child has its own... (1 Reply)
Discussion started by: tomlee
1 Replies

8. Shell Programming and Scripting

Need help writing shell script!

Hi, I'm very new to this, so bear with me please. I want to write a sh script (or if there's a better format please let me know) that allows me to, when I run it, print the date to a file (1.out) take 2 arguments (files a.fa and b.fa), run them with another program, outputting to 2.out, and then... (2 Replies)
Discussion started by: ShiGua
2 Replies

9. UNIX for Dummies Questions & Answers

Need help in writing shell script

Dear Team, Below is the list of steps i need to perform manually as of now and completely new to shell scripting, could you help in writing a shell script to perform the below procedure? 1. Log in to primary DNS server 2. Check /etc/named.conf if zone is already created (grep –i... (2 Replies)
Discussion started by: VKIRUPHAKARAN
2 Replies

10. Shell Programming and Scripting

Seeking assistance in Shell script

#!/bin/bash >error_log for s in `cat s.txt` do uptime $s >>error_log echo $s >>error_log done The above code produce output with server name and its uptime in 2 different lines .My requirement is to have the same in one line . Please assist (3 Replies)
Discussion started by: vinil
3 Replies
CATCODEC(1)						    BSD General Commands Manual 					       CATCODEC(1)

NAME
catcodec -- An open source tool to decode/encode the sample catalogue for OpenTTD SYNOPSIS
catcodec [-d sample_file] [-e sample_file] DESCRIPTION
catcodec decodes and encodes sample catalogues for OpenTTD. These sample catalogues are not much more than some meta-data (description and file name) and raw PCM data. Decoding a sample catalogue, e.g. sample.cat, results in a sample.sfo that contains the file names and descriptions of the samples and all samples with the file name as specified in the catalogue. Encoding a sample catalogue, e.g. sample.cat, reads sample.sfo for the file names and descriptions. It will then load the samples described in sample.sfo and encodes these into sample.cat. Generally speaking encoding a file and then decoding it results in the same file. Decoding of the original, Transport Tycoon Deluxe, sample format will force the output to be 11025 Hz, 8 bits mono because the meta-data of some of the samples is incorrect or even missing. Only PCM WAVE files with only the format and data chunks are supported. Any other formats need to be converted into this. Furthermore only 11025 Hz, 22050 Hz and 44100 Hz with 8 or 16 bits per sample single channel PCM WAVE files are supported. OPTIONS
-d sample_file Decode the given sample catalogue into its components. The sample_file must have the extension '.cat'. For the output meta- data file the '.cat' is replaced with '.sfo'. The actual samples, in PCM WAVE format, are extracted into files using the file names, including extension, as described in the catalogue or meta-data file. If any of the files already exists a backup is made, by adding '.bak', overwriting the existing backup. -e sample_file Encode the components for the given sample file into a sample catalogue. The sample_file must have the extension '.cat'. For the input meta-data file the '.cat' is replaced with '.sfo'. The actual samples, in PCM WAVE format, are read from files using the file names, including extension, as described in the meta-data file. If the sample_file already exists a backup is made, by adding '.bak', overwriting the existing backup. SEE ALSO
openttd(1) the game that uses these sample catalogues. AUTHORS
Remko Bijker <rubidium@openttd.org> November 05, 2009
All times are GMT -4. The time now is 08:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy