The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Operating Systems > AIX
.
google unix.com



AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Extract info chm0dvii AIX 1 01-18-2008 09:01 PM
How can I get multiple info from different files efernandes Shell Programming and Scripting 3 02-07-2007 06:54 PM
using cut to extract info hafhaq UNIX for Dummies Questions & Answers 4 10-04-2005 10:33 AM
I need a script that script extract info from mail meravd Shell Programming and Scripting 1 10-19-2004 12:15 PM
rewrite the same info in 3 different files strok Shell Programming and Scripting 6 03-29-2003 01:50 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-07-2007
kirantalla kirantalla is offline
Registered User
  
 

Join Date: Jul 2007
Location: Singapore
Posts: 8
need to extract info from log files

hi guys i need to extract information from log files generated by an application.


log file has the following lines for each process..
----------------------------------------------

Fri Aug 03 12:06:43 WST 2007 INFO: Running project PROJECT1
Fri Aug 03 12:06:43 WST 2007 INFO: Source Files For Project:PROJECT1
Fri Aug 03 12:06:43 WST 2007 INFO: [0]=/full/path/to/the/pdf/file/file name 001.pdf
Fri Aug 03 12:07:41 WST 2007 INFO: Done GC=1186114061306
Fri Aug 03 12:07:41 WST 2007 INFO: Returning true from deleteSources()
Fri Aug 03 12:07:41 WST 2007 INFO: Done running project PROJECT1

Fri Aug 03 12:06:43 WST 2007 INFO: Running project PROJECT2
Fri Aug 03 12:06:43 WST 2007 INFO: Source Files For Project:PROJECT2
Fri Aug 03 12:06:43 WST 2007 INFO: [0]=/full/path/to/the/pdf/file/file name 002.pdf
Fri Aug 03 12:07:30 WST 2007 INFO: Running plugin Extract Data from PDF
Fri Aug 03 12:07:30 WST 2007 INFO: Starting runPlugin()
Fri Aug 03 12:07:41 WST 2007 ERROR: Cannot process the file
Fri Aug 03 12:07:41 WST 2007 INFO: Done running project PROJECT2

Fri Aug 03 12:06:43 WST 2007 INFO: Running project PROJECT3
Fri Aug 03 12:06:43 WST 2007 INFO: Source Files For Project:PROJECT3
Fri Aug 03 12:06:43 WST 2007 INFO: [0]=/full/path/to/the/pdf/file/file name 003.pdf
Fri Aug 03 12:07:30 WST 2007 INFO: Running plugin Extract Data from PDF
Fri Aug 03 12:07:30 WST 2007 INFO: Starting runPlugin()
Fri Aug 03 12:07:41 WST 2007 ERROR: File Rollback
Fri Aug 03 12:07:41 WST 2007 INFO: Done running project PROJECT3

Result

file name 001.pdf : Success
file name 002.pdf : Failed
file name 003.pdf : Rollback


i could only extract the lines, but i could not format the output.. hope i will get a solution.

thanx

Last edited by kirantalla; 08-20-2007 at 05:18 AM..
  #2 (permalink)  
Old 08-07-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
  
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Kirantalla,
Your solution is very involved, as it requires date difference.

A complete solution must consider your times could be in different days,
your days could be in different months and your months could be in different
years, not forgetting leap years.

It requires a considerable amount of time and coding.

Is there an alternative way to display the dates as it appears in the file
without any conversion?

Can the reader visually subtract the difference?
  #3 (permalink)  
Old 08-07-2007
kirantalla kirantalla is offline
Registered User
  
 

Join Date: Jul 2007
Location: Singapore
Posts: 8
hi shelllife,

thanx for the reply. the extracted info is not for a user but is actually an input file for another process.

the date is not a consideration bcoz the whole process will not take more than a day .. if it crosses one day, the process is killed and restarted. so the extracted time will be within 24 hours.

thx
  #4 (permalink)  
Old 08-10-2007
fazliturk fazliturk is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 45
which line is the filename ? *spaces.pdf or PY_ZHRPY_RCN02-AWSR
how can we match the error ? will it be written as ERROR ?
will there be more than one project in a log file
  #5 (permalink)  
Old 08-12-2007
kirantalla kirantalla is offline
Registered User
  
 

Join Date: Jul 2007
Location: Singapore
Posts: 8
thx fazliturk for the reply,

ok the file name can be anywhere in between the "Running project <projectname>" and "Done running project <projectname>" and will always a .pdf file and will be the only one name in between the "Running project" and "Done running project"
there will be a lot of projects in the log file .. and the pattern will be

Running project <ProjectName1>
[0]=/machine name/project name/queue name/file name1.pdf
ERROR=<Any Errors here>
Done running project<ProjectName1>
Running project <ProjectName2>
[0]=/machine name/project name/queue name/file name2.pdf
Done running project<ProjectName2>
Running project <ProjectName3>
[0]=/machine name/project name/queue name/file name3.pdf
Done running project<ProjectName3>
Running project <ProjectName4>
[0]=/machine name/project name/queue name/file name4.pdf
ERROR=<Any Errors here>
Done running project<ProjectName4>

file name and directory names will also have spaces

other information is also embedded in between the "Running" and "Done" lines.
  #6 (permalink)  
Old 08-14-2007
kah00na kah00na is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 79
I'd suggest converting your dates to epoch time, that makes subtraction much easier, then converting that back to minutes, hours, or what ever else you want.
  #7 (permalink)  
Old 08-14-2007
kah00na kah00na is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 79
Here's a script to convert dates into epoch time named "epoch":

Code:
##*******************************************************************************
## Script       epoch
## Purpose      Take date in formatted string as an argument and coverts it
##              into epoch time (seconds since 1/1/1970)
## Usage        ./epoch Aug 25 23:59:59 2007 GMT
##===============================================================================
## History
## 2007/01/15  Big Kahoona   Creation of script (some code from the internet)
##*******************************************************************************

year=$4
month=$1
day=$2
hour=$(echo $3 | cut -d: -f1)
min=$(echo $3 | cut -d: -f2)
sec=$(echo $3 | cut -d: -f3)
tz=$5

# Convert month to number
if [ $month = "Jan" ]; then
        month=1
elif [ $month = "Feb" ]; then
        month=2
elif [ $month = "Mar" ]; then
        month=3
elif [ $month = "Apr" ]; then
        month=4
elif [ $month = "May" ]; then
        month=5
elif [ $month = "Jun" ]; then
        month=6
elif [ $month = "Jul" ]; then
        month=7
elif [ $month = "Aug" ]; then
        month=8
elif [ $month = "Sep" ]; then
        month=9
elif [ $month = "Oct" ]; then
        month=10
elif [ $month = "Nov" ]; then
        month=11
elif [ $month = "Dec" ]; then
        month=12
fi

# leap days in past years
leapdays=$(( (year - 1969)/4 ))

# Is this year a leap year?
leap=$(( year % 4 == 0 ))

# Days in each month this year.
mdays[1]=31
mdays[2]=$((28+leap))
mdays[3]=31
mdays[4]=30
mdays[5]=31
mdays[6]=30
mdays[7]=31
mdays[8]=31
mdays[9]=30
mdays[10]=31
mdays[11]=30
mdays[12]=31

# days since the epoch, not counting earlier months this year
daycount=$(( (year - 1970) * 365 + leapdays + day - 1))

# Step through earlier months this year and add the days
m=$((month - 1))
while [ $m -ge 1 ]; do
        #echo "month=$m"
        daycount=$((daycount+${mdays[$m]} ))
        m=$((m-1))
done

# Now the seconds
epoch=$(( ( (daycount * 24 + hour) * 60 + min) * 60 + sec ))

# Add the time zones that apply to you
case "$tz" in
        #GMT) epoch=$((epoch + 0));;
        #EST) epoch=$((epoch + 18000));;
        CST) epoch=$((epoch + 21600));;
        #GMT) epoch=$((epoch + 21600));;
        #*)   epoch="ERROR: unrecognized on time zone";;
esac
echo "${epoch}"
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:29 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0