![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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.. |
|
||||
|
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 |
|
||||
|
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. |
|
||||
|
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}"
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|