Solved

Command which acts on the contents of logs

Posted on 2000-05-05
3
255 Views
Last Modified: 2010-04-20
Hello All.
 I am sure I have seen this somewhere, but I cannot find it again. Is there a program that watches the end of a file as it grows (like a log file), and executes a user defined script when certain text appears in the log. If not, how can this be done.

Thanks in advance,
Nicholas Waltham
0
Comment
Question by:nwaltham
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 40

Expert Comment

by:jlevie
ID: 2782543
"tail -f some-file" watches the end of a file, continuously showing it's content as new info is added. You could pipe that to a script to watch for a specific string and it could act accordingly.
0
 
LVL 15

Accepted Solution

by:
samri earned 50 total points
ID: 2787266
nwaltham,

Just some addition (in addtion to jlevie comment :)

tail -f some-file | egrep "some pattern" | you-home-made-script.sh

Maybe you are looking for "login" in /var/adm/message

tail -f /var/adm/message | egrep "login" | logwatcher.sh

should do.  and don't forget that you need to write the "lgowatcher.sh" script yourself.

:)
0
 
LVL 2

Expert Comment

by:EatEmAndSmile
ID: 2788589
Exactly. The "cut" command will provide the filter to grab the interesting part of the text you need.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question