Script for parsing details in a log file to a seperate file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Script for parsing details in a log file to a seperate file
# 1  
Old 11-13-2008
Script for parsing details in a log file to a seperate file

Hi Experts,

Im a new bee for scripting,

I would ned to do the following via linux shell scripting, I have an application which throws a log file, on each action of a particular work with the application, as sson as the action is done, the log file would vanish or stops updating there, the action apparently invokes another application related.

So now my task would be to see the logfile that is generated each time.

please chk this

My script would have to regularly check the following directory (which will vary with the system name)

/usr/fl/log/*-fsm-server-*/

for a file called

console.txt

That file only exists for as long as the process is running (so your
script will have to poll that directory regularly). It contains
pathnames to the footage being copied.


here the * represents the numbers on each instance,

So i need to poll this directory and check for the latest log file, and grep the essential info............



How im not confusing...............if possible help me out............i shall explain better if needed.Smilie
# 2  
Old 11-13-2008
Quote:
so your script will have to
Is this homework/classroom stuff or is that an instruction for us to write your script? Either would not be nice Smilie

Nevertheless, something to start with:

- set it up as a cronjob
- "ls -latr" will give you the latest file in a directory
- if you have to be recursively, use -R or use find, maybe in combination with ls or something, whatever you need
- to check if a file is there or not, use something like
Code:
...
if [[ ! -e /my/dir/file.txt ]]; then
    echo "The file is not there!"| mail -s "alarm" you@domain.org
fi
...

GL

# 3  
Old 11-13-2008
thanks,

as you said, yes i can cron, but my tricky thing is to know the directory as well i.e

/usr/fl/log/*....something...*/console.txt

here both the * are the variables that may change any time nather created when the other application is invoked.

Im good at troubleshooting, but new to scripting, so i think im explaining in a better way.

so the task would also involve finding the newly created directory on a periodic basis and the browse the console.txt file, then grep the particular line that has been there and then touch that to the file.

for fine tuning i think i should try to add the time when the directory was created in the new log file, so that i get a proper history after a due course of time..............


thanks in advance pals............. see u soonSmilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Generic script to load file details(ls -ltr) in to a database.

All, I am trying to create a report on the duration of an ETL load from the file arrival to the final dump in to a database for SLA's. Does anyone have any guidance or ideas on how metadata can be extracted; information of a file: like file name, created timestamp, count of records and load... (1 Reply)
Discussion started by: pradeepp
1 Replies

2. UNIX for Beginners Questions & Answers

Fetching address and user details from log file

Hi All, I have a requirement to get the address values from a large log file along with the user details. line1,line2,city,stateCode,postalCode,countryCode. The below code as advised in the earlier post is giving the user data zgrep -B1 "Failed to calculate Tax" log.2018-05-23.gz | grep... (8 Replies)
Discussion started by: nextStep
8 Replies

3. Shell Programming and Scripting

Parsing a log file and creating a report script

The log file is huge and lot of information, i would like to parse and make a report . below is the log file looks like: REPORT DATE: Mon Aug 10 04:16:17 CDT 2017 SYSTEN VER: v1.3.0.9 TERMINAL TYPE: prod SYSTEM: nb11cu51 UPTIME: 04:16AM up 182 days 57 mins min MODEL, TYPE, and SN:... (8 Replies)
Discussion started by: amir07
8 Replies

4. Shell Programming and Scripting

How to log file processing details to database table usnig UNIX shell script?

we are getting files on daily basis.we need to process these files. i need a unix shell script where we can count 1-The no of files processed 2-No of data/record processed for each files. The script should log these details into a database table. If there is any error while file... (3 Replies)
Discussion started by: Atul kumar
3 Replies

5. Shell Programming and Scripting

Issue with awk script parsing log file

Hello All, I am trying to parse a log file and i got this code from one of the good forum colleagues, However i realised later there is a problem with this awk script, being naive to awk world wanted to see if you guys can help me out. AWK script: awk '$1 ~ "^WRITER_" {p=1;next}... (18 Replies)
Discussion started by: Ariean
18 Replies

6. Shell Programming and Scripting

Script for Parsing Log File

Working on a script that inputs an IP, parses and outputs to another file. A Sample of the log is as follows: I need the script to be able to input IP and print the data in an output file in the following format or something similar: Thanks for any help you can give me! (8 Replies)
Discussion started by: Winsarc
8 Replies

7. Shell Programming and Scripting

Help with script parsing a log file

I have a large log file, which I want to first use grep to get the specific lines then send it to awk to print out the specific column and if the result is zero, don't do anything. What I have so far is: LOGDIR=/usr/local/oracle/Transcription/log ERRDIR=/home/edixftp/errors #I want to be... (3 Replies)
Discussion started by: mevasquez
3 Replies

8. Shell Programming and Scripting

Shell script for parsing 300mb log file..

am relatively new to Shell scripting. I have written a script for parsing a big file. The logic is: Apart from lot of other useless stuffs, there are many occurances of <abc> and corresponding </abc> tags. (All of them are properly closed) My requirement is to find a particular tag (say... (3 Replies)
Discussion started by: gurpreet470
3 Replies

9. UNIX for Dummies Questions & Answers

logging SFTP details in a log file...

hi all..... i want to know how to log the details when logging into a server using SFTP......in FTP i used something like (ftp -uv<xxx.srp>>log_file.log) where the details will be logged to log_file...is there any options for doing the same in SFTP....i wanted to display the details abt... (4 Replies)
Discussion started by: santy
4 Replies

10. Shell Programming and Scripting

Read relevent details from Log File

Hi All, We have requirement to read XML details from large Log File and save in new file name. I have enclosed the sample xml which has start tag <OUTBOUND_MESSAGE xmlns="http://www.abc.com"> and the end tag as </OUTBOUND_MESSAGE> The log file contains many lines with other details which... (6 Replies)
Discussion started by: thinakarmani
6 Replies
Login or Register to Ask a Question