sysmicuser |
03-07-2012 06:28 AM |
Need help with parsing log file
Hi Guru's,
I need some assistance from you in regards to parsing a log file.
What my aim or objective is to have a "Report" which would report files which have been added by user and not submitted to repository(Perforce) or any such file which is edited and changes not submitted to repository.
I am not writing here actual script as it is pretty staright forward and command it executes is pretty much p4 diff -f <file_name>...
What I am definitely writing is my grep command of script(set -xv)
Code:
echo "Following files are differing from repository, please submit them to repository"
++ echo 'Following files are differing from repository, please submit them to repository'
Following files are differing from repository, please submit them to repository
grep -E -v "===" -E "file(s) not on client" $LOGS_DIR/p4_opened_files.sh.log > /tmp/$$
++ grep -E -v === -E 'file(s) not on client' test/logs/p4_opened_files.sh.log
grep: file(s) not on client: No such file or directory
mailx -s "Opened files Report" test@testme.com < /tmp/$$
++ mailx -s 'Opened files Report' test@testme.com
Email which I get has following output.
Code:
test/logs/p4_opened_files.sh.log:batch - file(s) not on client.
test/logs/p4_opened_files.sh.log:build_essentials - file(s) not on client.
test/logs/p4_opened_files.sh.log:ccb_batch_restart_worker.sh.20120302 - file(s) not on client.
test/logs/p4_opened_files.sh.log:ccb_spl_ear_undeploy.sh - file(s) not on client.
test/logs/p4_opened_files.sh.log:orig_split_spl_ear.xml - file(s) not on client.
test/logs/p4_opened_files.sh.log:archive - file(s) not on client.
test/logs/p4_opened_files.sh.log:build_essentials - file(s) not on client.
testl/ogs/p4_opened_files.sh.log:check_disk_space.sh_BACKUP - file(s) not on client.
test/logs/p4_opened_files.sh.log:password.txt - file(s) not on client.
test/logs/p4_opened_files.sh.log:549c549
test/logs/p4_opened_files.sh.log:< ant clean build deploy 2>&1 | tee -a ${IGL_LOGFILE}
test/logs/p4_opened_files.sh.log:---
test/logs/p4_opened_files.sh.log:> ant -v clean build deploy 2>&1 | tee -a ${IGL_LOGFILE}
test/logs/p4_opened_files.sh.log:560c560
test/logs/p4_opened_files.sh.log:< ant clean build 2>&1 | tee -a ${IGL_LOGFILE}
test/logs/p4_opened_files.sh.log:---
test/logs/p4_opened_files.sh.log:> ant -v clean build 2>&1 | tee -a ${IGL_LOGFILE}
test/logs/p4_opened_files.sh.log:* - file(s) not on client.
test/logs/p4_opened_files.sh.log:oas_opmn_start.sh - file(s) not on client.
test/logs/p4_opened_files.sh.log:oas_opmn_stop.sh - file(s) not on client.
test/logs/p4_opened_files.sh.log:cdc_jobs - file(s) not on client.
test/logs/p4_opened_files.sh.log:set_bld02.sh - file(s) not on client.
The actual logfile output is.
Code:
batch - file(s) not on client.
build_essentials - file(s) not on client.
ccb_batch_restart_worker.sh.20120302 - file(s) not on client.
ccb_spl_ear_undeploy.sh - file(s) not on client.
orig_split_spl_ear.xml - file(s) not on client.
archive - file(s) not on client.
build_essentials - file(s) not on client.
check_disk_space.sh_BACKUP - file(s) not on client.
password.txt - file(s) not on client.
==== //glide/main/scm/ahscripts/common/build_and_deploy.sh#23 - test/ahscripts/common/build_and_deploy.sh ====
549c549
< ant clean build deploy 2>&1 | tee -a ${IGL_LOGFILE}
---
> ant -v clean build deploy 2>&1 | tee -a ${IGL_LOGFILE}
560c560
< ant clean build 2>&1 | tee -a ${IGL_LOGFILE}
---
> ant -v clean build 2>&1 | tee -a ${IGL_LOGFILE}
* - file(s) not on client.
oas_opmn_start.sh - file(s) not on client.
oas_opmn_stop.sh - file(s) not on client.
cdc_jobs - file(s) not on client.
set_bld02.sh - file(s) not on client.
==== //glide/main/scm/ahscripts/tomcat/tomcat_stop.sh#1 - test/ahscripts/tomcat/tomcat_stop.sh ====
The above output(in email) I do care, issue with it is.
1. it should only output file name and not whole path.
for example
Instead of
test/logs/p4_opened_files.sh.log:password.txt - file(s) not on client.
It should say
password.txt
2. Second Issue is I believe more complex to script
Have a look at actual log file output.
Code:
==== //glide/main/scm/ahscripts/common/build_and_deploy.sh#23 - test/ahscripts/common/build_and_deploy.sh ====
549c549
< ant clean build deploy 2>&1 | tee -a ${IGL_LOGFILE}
---
> ant -v clean build deploy 2>&1 | tee -a ${IGL_LOGFILE}
560c560
< ant clean build 2>&1 | tee -a ${IGL_LOGFILE}
---
> ant -v clean build 2>&1 | tee -a ${IGL_LOGFILE}
* - file(s) not on client.
oas_opmn_start.sh - file(s) not on client.
But in email I get some non-friendly output...
Code:
test/logs/p4_opened_files.sh.log:password.txt - file(s) not on client.
test/logs/p4_opened_files.sh.log:549c549
test/logs/p4_opened_files.sh.log:< ant clean build deploy 2>&1 | tee -a ${IGL_LOGFILE}
test/logs/p4_opened_files.sh.log:---
test/logs/p4_opened_files.sh.log:> ant -v clean build deploy 2>&1 | tee -a ${IGL_LOGFILE}
test/logs/p4_opened_files.sh.log:560c560
test/logs/p4_opened_files.sh.log:< ant clean build 2>&1 | tee -a ${IGL_LOGFILE}
test/logs/p4_opened_files.sh.log:---
test/logs/p4_opened_files.sh.log:> ant -v clean build 2>&1 | tee -a ${IGL_LOGFILE}
test/logs/p4_opened_files.sh.log:* - file(s) not on client.
Instead it should give only name of file that is build_and_deploy.sh
How can I achieve my objective?
Please assist me here.
Many Thanks.
|