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
RCSFREEZE(1)						      General Commands Manual						      RCSFREEZE(1)

NAME
rcsfreeze - freeze a configuration of sources checked in under RCS SYNOPSIS
rcsfreeze [name] DESCRIPTION
rcsfreeze assigns a symbolic revision number to a set of RCS files that form a valid configuration. The idea is to run rcsfreeze each time a new version is checked in. A unique symbolic name (C_number, where number is increased each time rcsfreeze is run) is then assigned to the most recent revision of each RCS file of the main trunk. An optional name argument to rcsfreeze gives a symbolic name to the configuration. The unique identifier is still generated and is listed in the log file but it will not appear as part of the symbolic revision name in the actual RCS files. A log message is requested from the user for future reference. The shell script works only on all RCS files at one time. All changed files must be checked in already. Run rcsclean(1) first and see whether any sources remain in the current directory. FILES
RCS/.rcsfreeze.ver version number RCS/.rcsfreeze.log log messages, most recent first AUTHOR
Stephan v. Bechtolsheim SEE ALSO
co(1), rcs(1), rcsclean(1), rlog(1) BUGS
rcsfreeze does not check whether any sources are checked out and modified. Although both source file names and RCS file names are accepted, they are not paired as usual with RCS commands. Error checking is rudimentary. rcsfreeze is just an optional example shell script, and should not be taken too seriously. See CVS for a more complete solution. GNU RCSFREEZE(1)
All times are GMT -4. The time now is 05:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy