[groovy-user] Regex to read the second line

34 views
Skip to first unread message

buildscm

unread,
Dec 9, 2010, 2:56:28 PM12/9/10
to us...@groovy.codehaus.org

http://groovy.329449.n5.nabble.com/file/n3299395/regex_detail.txt
regex_detail.txt


Hi all,

I have a log file which contains the following error in that log file.

[exec] "//'TEST.BUILD.LNGSRC(APPQFILE)'", line 15524.46: CCN8924 (W)
Cannot pass an argument of non-POD class type
[exec] "eString" through ellipsis.
[exec] !! END OF JES SPOOL FILE !!
[exec] "//'TEST.BUILD.LNGSRC(APPQUEUE)'", line 3050.65: CCN8924 (W)
Cannot pass an argument of non-POD class type
[exec] "eString" through ellipsis.
[exec] "//'TEST.BUILD.LNGSRC(APPQUEUE)'", line 3050.76: CCN8924 (W)
Cannot pass an argument of non-POD class type
[exec] "eString" through ellipsis.
[exec] "//'TEST.BUILD.LNGSRC(BARCODE)'", line 3832.56: CCN5216 (W) An
expression of type "extern "C" void (*)()" cannot
[exec] be converted to type "int (**)(const char *)".
[exec] "//'TEST.BUILD.S6019.LNGSRC(BARCODE)'", line 3847.57: CCN5216
(W) An expression of type "extern "C" void (*)()" cannot
[exec] be converted to type "int (**)(tag_BarCode *&, const char *,
long, short, int, int, int, int &)".
[exec] "//'TEST.BUILD.LNGSRC(BARCODE)'", line 3882.58: CCN5216 (W) An
expression of type "extern "C" void (*)()" cannot
[exec] be converted to type "int (**)()".
[exec] CCN0793(I) Compilation failed for file
//'TEST.BUILD.S6019.LNGSRC(BARCODE)'. Object file not created.

I wrote a regex to capture this error from the log file, but my regex reads
only if the error is in one line it gives me exact result, but it the error
spitls on second line, it is not capturing the second line

Here is my regex
// REPLACE THESE REGEX'S.
error_patterns = [
Pattern.compile(/^.*: CCN[\w|\s]*.*$/,Pattern.MULTILINE),
Pattern.compile(/^.*Object file not
created[\w|\s]*.*$/,Pattern.MULTILINE),
Pattern.compile(/^.*ALLOCATION FAILED DUE[\w|\s]*.*$/,Pattern.MULTILINE),
Pattern.compile(/^.*DUPLICATE NAME EXISTS[\w|\s]*.*$/,Pattern.MULTILINE),
Pattern.compile(/^.*\(S\).*$/, Pattern.MULTILINE)
]
fname_ptn = Pattern.compile(/.*\/(.*)/,Pattern.CASE_INSENSITIVE)

log_file.readLines().each { line ->
error_patterns.each { ptn ->
m = ptn.matcher(line)
while (m.find()) {
error_lines << m.group()
}
}
}

with the above regex i get the result as below.

[exec] "//'TEST.BUILD.LNGSRC(APPQFILE)'", line 15524.46: CCN8924 (W) Cannot
pass an argument of non-POD class type
[exec] "//'TEST.BUILD.LNGSRC(APPQUEUE)'", line 3050.65: CCN8924 (W) Cannot
pass an argument of non-POD class type
[exec] "//'TEST.BUILD.LNGSRC(APPQUEUE)'", line 3050.76: CCN8924 (W) Cannot
pass an argument of non-POD class type
[exec] "//'TEST.BUILD.LNGSRC(BARCODE)'", line 3832.56: CCN5216 (W) An
expression of type "extern "C" void (*)()" cannot
[exec] "//'TEST.BUILD.S6019.LNGSRC(BARCODE)'", line 3847.57: CCN5216 (W) An
expression of type "extern "C" void (*)()" cannot
[exec] "//'TEST.BUILD.LNGSRC(BARCODE)'", line 3882.58: CCN5216 (W) An
expression of type "extern "C" void (*)()" cannot


I want the result like this with second line also.

[exec] "//'TEST.BUILD.LNGSRC(APPQFILE)'", line 15524.46: CCN8924 (W)
Cannot pass an argument of non-POD class type
[exec] "eString" through ellipsis.
[exec] !! END OF JES SPOOL FILE !!
[exec] "//'TEST.BUILD.LNGSRC(APPQUEUE)'", line 3050.65: CCN8924 (W)
Cannot pass an argument of non-POD class type
[exec] "eString" through ellipsis.
[exec] "//'TEST.BUILD.LNGSRC(APPQUEUE)'", line 3050.76: CCN8924 (W)
Cannot pass an argument of non-POD class type
[exec] "eString" through ellipsis.
[exec] "//'TEST.BUILD.LNGSRC(BARCODE)'", line 3832.56: CCN5216 (W) An
expression of type "extern "C" void (*)()" cannot
[exec] be converted to type "int (**)(const char *)".
[exec] "//'TEST.BUILD.S6019.LNGSRC(BARCODE)'", line 3847.57: CCN5216
(W) An expression of type "extern "C" void (*)()" cannot
[exec] be converted to type "int (**)(tag_BarCode *&, const char *,
long, short, int, int, int, int &)".
[exec] "//'TEST.BUILD.LNGSRC(BARCODE)'", line 3882.58: CCN5216 (W) An
expression of type "extern "C" void (*)()" cannot
[exec] be converted to type "int (**)()".
[exec] CCN0793(I) Compilation failed for file
//'TEST.BUILD.S6019.LNGSRC(BARCODE)'. Object file not created.

can you please suggest or send me a regex or correct my regex to get the
expected result.

I have also uploaded a txt file to show the format clearly, if the alignment
of the text changes in my post.

Thanks.
--
View this message in context: http://groovy.329449.n5.nabble.com/Regex-to-read-the-second-line-tp3299395p3299395.html
Sent from the groovy - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Victor Grazi

unread,
Dec 9, 2010, 3:20:28 PM12/9/10
to us...@groovy.codehaus.org

Try DOT_ALL instead of MULTI_LINE

buildscm

unread,
Dec 9, 2010, 4:14:16 PM12/9/10
to us...@groovy.codehaus.org

Hi Victor,

Thanks for responding to my post quickly.

I tried with DOT_ALL, i got the following error.

ERROR: Publisher hudson.plugins.emailext.ExtendedEmailPublisher aborted due
to exception
java.lang.RuntimeException: Error using the template
at
hudson.plugins.emailext.plugins.ContentBuilder.transformUsingScript(ContentBuilder.java:224)
at
hudson.plugins.emailext.plugins.ContentBuilder.transformText(ContentBuilder.java:71)
at
hudson.plugins.emailext.ExtendedEmailPublisher.createMail(ExtendedEmailPublisher.java:266)
at
hudson.plugins.emailext.ExtendedEmailPublisher.sendMail(ExtendedEmailPublisher.java:225)
at
hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:216)
at
hudson.plugins.emailext.ExtendedEmailPublisher.perform(ExtendedEmailPublisher.java:176)
at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36)
at
hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:601)
at
hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:580)
at
hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:558)
at hudson.model.Build$RunnerImpl.cleanUp(Build.java:166)
at hudson.model.Run.run(Run.java:1322)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:137)
Caused by: groovy.lang.MissingPropertyException: No such property: DOT_ALL
for class: java.util.regex.Pattern
at
groovy.lang.MetaClassImpl.invokeStaticMissingProperty(MetaClassImpl.java:882)
at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:1591)
at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:1567)
at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:3275)
at
org.codehaus.groovy.runtime.callsite.ClassMetaClassGetPropertySite.getProperty(ClassMetaClassGetPropertySite.java:42)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:236)
at SimpleTemplateScript10.run(SimpleTemplateScript10.groovy:112)
at
groovy.text.SimpleTemplateEngine$SimpleTemplate$1.writeTo(SimpleTemplateEngine.java:112)
at
groovy.text.SimpleTemplateEngine$SimpleTemplate$1.toString(SimpleTemplateEngine.java:124)
at
hudson.plugins.emailext.plugins.ContentBuilder.transformUsingScript(ContentBuilder.java:219)
... 14 more


I am using
import java.util.regex.Matcher
import java.util.regex.Pattern


Thanks.

--
View this message in context: http://groovy.329449.n5.nabble.com/Regex-to-read-the-second-line-tp3299395p3299490.html

buildscm

unread,
Dec 9, 2010, 4:18:12 PM12/9/10
to us...@groovy.codehaus.org

I think i have to use DOTALL
--
View this message in context: http://groovy.329449.n5.nabble.com/Regex-to-read-the-second-line-tp3299395p3299495.html

Paul King

unread,
Dec 9, 2010, 5:04:45 PM12/9/10
to us...@groovy.codehaus.org
Not 100% sure what you want but something like thhis might work:

def ptn = java.util.regex.Pattern.compile(/(?si)\s*\[exec\]\s+"\/\/'(?:.(?!\s*\[exec\]\s+"\/\/'))*/)
def error_lines = []

log_file.eachMatch(ptn) {
error_lines << it
}
println error_lines

Cheers, Paul.

On 10/12/2010 5:56 AM, buildscm wrote:
>
> http://groovy.329449.n5.nabble.com/file/n3299395/regex_detail.txt
> regex_detail.txt
>
>
> Hi all,
>
> I have a log file which contains the following error in that log file.
>
> [exec] "//'TEST.BUILD.LNGSRC(APPQFILE)'", line 15524.46: CCN8924 (W)
> Cannot pass an argument of non-POD class type
> [exec] "eString" through ellipsis.
> [exec] !! END OF JES SPOOL FILE !!
> [exec] "//'TEST.BUILD.LNGSRC(APPQUEUE)'", line 3050.65: CCN8924 (W)
> Cannot pass an argument of non-POD class type
> [exec] "eString" through ellipsis.
> [exec] "//'TEST.BUILD.LNGSRC(APPQUEUE)'", line 3050.76: CCN8924 (W)
> Cannot pass an argument of non-POD class type
> [exec] "eString" through ellipsis.
> [exec] "//'TEST.BUILD.LNGSRC(BARCODE)'", line 3832.56: CCN5216 (W) An
> expression of type "extern "C" void (*)()" cannot
> [exec] be converted to type "int (**)(const char *)".
> [exec] "//'TEST.BUILD.S6019.LNGSRC(BARCODE)'", line 3847.57: CCN5216
> (W) An expression of type "extern "C" void (*)()" cannot
> [exec] be converted to type "int (**)(tag_BarCode *&, const char *,

> long, short, int, int, int, int&)".

> long, short, int, int, int, int&)".


> [exec] "//'TEST.BUILD.LNGSRC(BARCODE)'", line 3882.58: CCN5216 (W) An
> expression of type "extern "C" void (*)()" cannot
> [exec] be converted to type "int (**)()".
> [exec] CCN0793(I) Compilation failed for file
> //'TEST.BUILD.S6019.LNGSRC(BARCODE)'. Object file not created.
>
> can you please suggest or send me a regex or correct my regex to get the
> expected result.
>
> I have also uploaded a txt file to show the format clearly, if the alignment
> of the text changes in my post.
>
> Thanks.

buildscm

unread,
Dec 10, 2010, 12:27:37 PM12/10/10
to us...@groovy.codehaus.org

Hi Paul,

Thanks for sending the regex , i tried your regex like this

// REPLACE THESE REGEX'S.

def error_patterns =

java.util.regex.Pattern.compile(/(?si)\s*\[exec\]\s+"\/\/'(?:.(?!\s*\[exec\]\s+"\/\/'))*/,
Pattern.MULTILINE)

def error_lines =[]

log_file.eachMatch(error_patterns){ line ->


error_patterns.each { ptn ->
m = ptn.matcher(line)
while (m.find()) {
error_lines << m.group()
}
}
}


i am getting following error.

Caused by: groovy.lang.MissingMethodException: No signature of method:
java.io.File.eachMatch() is applicable for argument types:
(java.util.regex.Pattern, SimpleTemplateScript54$_run_closure2) values:
[(?si)\s*\[exec\]\s+"//'(?:.(?!\s*\[exec\]\s+"//'))*,
SimpleTemplateScript54$_run_closure2@ad0c5d]
at
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:54)
at
org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:48)
at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:43)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
at SimpleTemplateScript54.run(SimpleTemplateScript54.groovy:116)


at
groovy.text.SimpleTemplateEngine$SimpleTemplate$1.writeTo(SimpleTemplateEngine.java:112)
at
groovy.text.SimpleTemplateEngine$SimpleTemplate$1.toString(SimpleTemplateEngine.java:124)
at
hudson.plugins.emailext.plugins.ContentBuilder.transformUsingScript(ContentBuilder.java:219)
... 14 more

Finished: FAILURE

Thanks.
--
View this message in context: http://groovy.329449.n5.nabble.com/Regex-to-read-the-second-line-tp3299395p3300657.html


Sent from the groovy - user mailing list archive at Nabble.com.

---------------------------------------------------------------------

Victor Grazi

unread,
Dec 10, 2010, 1:50:10 PM12/10/10
to us...@groovy.codehaus.org

Have you tried this in a regex evaluator.

It's usually a good practice to debug your regex in a tool before trying to use it in your code

Good luck
Victor

buildscm

unread,
Dec 10, 2010, 2:03:37 PM12/10/10
to us...@groovy.codehaus.org

Hi Victor,

I tried in the regex (?si)\s*\[exec\]\s+"\/\/'(?:.(?!\s*\[exec\]\s+"\/\/'))*
in regexbuddy, i am getting the result what i want in the regexbuddy,

when i am trying to implement it in the code it is giving me the error. it
uses groovy.

thanks.
--
View this message in context: http://groovy.329449.n5.nabble.com/Regex-to-read-the-second-line-tp3299395p3300811.html

buildscm

unread,
Dec 10, 2010, 2:06:27 PM12/10/10
to us...@groovy.codehaus.org

i tried the following expression in regexbuddy.

^.*: CCN[\w|\s]*.*(.*\n){2}

it gives me the result, but when i implement in my groovy script. it is not
giving any result.

thanks.
--
View this message in context: http://groovy.329449.n5.nabble.com/Regex-to-read-the-second-line-tp3299395p3300816.html

buildscm

unread,
Dec 10, 2010, 2:17:55 PM12/10/10
to us...@groovy.codehaus.org

I used the DOTALL , it is not giving the required result.

thanks.
--
View this message in context: http://groovy.329449.n5.nabble.com/Regex-to-read-the-second-line-tp3299395p3300822.html

Paul King

unread,
Dec 10, 2010, 9:32:55 PM12/10/10
to us...@groovy.codehaus.org

The code I sent was the complete working version.
I am not sure what you are trying to do with your code below
but it doesn't seem right to have eachMatch (which returns
the final answer) and then be doing another matcher on it.

But perhaps I don't understand what you are doing.
Also, you won't want Pattern.MULTILINE as the (?s) part of
the prefix in the regex I sent you is the DOTALL notation
and the 'i' bit is the case insensitive part - so there
is nothing more required I would have thought.

Cheers,
Paul.

buildscm

unread,
Dec 13, 2010, 3:36:24 PM12/13/10
to us...@groovy.codehaus.org

Hi Paul,

Here is the code which i am using to parse the log, If you see i am making
any mistake can you please change it.

import java.util.regex.Matcher
import java.util.regex.Pattern

def lastSuccesfulBuild = build.previousNotFailedBuild
def failed = build.result != hudson.model.Result.SUCCESS

def currResult = build.result
def prevResult = build.previousBuild?.result ?: null

def consecutiveSuccess = currResult == hudson.model.Result.SUCCESS &&
prevResult == hudson.model.Result.SUCCESS

def builds = []
def changes = []
def authors = []
def count = 0

if(consecutiveSuccess){
builds << build
def changeItems = build.changeSet.items
count += changeItems.length
changes += changeItems as List
authors += changeItems.collect { item -> item.author.displayName }
}else{
lastSuccesfulBuild = lastSuccesfulBuild.nextBuild
while(lastSuccesfulBuild){
builds << lastSuccesfulBuild
def changeItems = lastSuccesfulBuild.changeSet.items
if (changeItems != null) {
count += changeItems.length
changes += changeItems as List
}
lastSuccesfulBuild = lastSuccesfulBuild.nextBuild
}
}

// parse the log file
log_file = build.logFile
error_lines = []

// REPLACE THESE REGEX'S.

error_patterns = [
Pattern.compile(/^.*: CCN[\w|\s]*.*$/,Pattern.MULTILINE),
Pattern.compile(/^.*Object file not
created[\w|\s]*.*$/,Pattern.MULTILINE),
Pattern.compile(/^.*ALLOCATION FAILED DUE[\w|\s]*.*$/,Pattern.MULTILINE),
Pattern.compile(/^.*DUPLICATE NAME EXISTS[\w|\s]*.*$/,Pattern.MULTILINE),
Pattern.compile(/^.*\(S\).*$/, Pattern.MULTILINE)
]

fname_ptn = Pattern.compile(/.*\/(.*)/,Pattern.CASE_INSENSITIVE)

log_file.readLines().each { line ->

error_patterns.each { ptn ->
m = ptn.matcher(line)
while (m.find()) {
error_lines << m.group()
}
}
}

breakage_changes = []
searched = []
// see if any of the files match the error logs.
changes.each { item ->
found = false
item.paths.each { path ->
if(!found) {
if(m != null && !searched.contains(m[0][1])) {
searched << m[0][1]
error_lines.each { el ->
if(el.toLowerCase() =~ m[0][1].toLowerCase() && !found) {
found=true
breakage_changes << [m[0][1], item]
}
}
}
}
}
}


Thanks.
--
View this message in context: http://groovy.329449.n5.nabble.com/Regex-to-read-the-second-line-tp3299395p3303720.html


Sent from the groovy - user mailing list archive at Nabble.com.

---------------------------------------------------------------------

buildscm

unread,
Dec 13, 2010, 4:18:07 PM12/13/10
to us...@groovy.codehaus.org

Hi Paul,

I used your regex in the script as follows

import java.util.regex.Matcher
import java.util.regex.Pattern

// REPLACE THESE REGEX'S.
error_patterns = [

Pattern.compile(/(?si)/s*\[exec\]\s+"\/\/'(?:.(?!\s*\[exec\]\s+"\/\/'))*/,Pattern.MULTILINE)
]

fname_ptn = Pattern.compile(/.*\/(.*)$/,Pattern.CASE_INSENSITIVE)

log_file.readLines().each { line ->


error_patterns.each { ptn ->
m = ptn.matcher(line)
while (m.find()) {
error_lines << m.group()
}
}
}

breakage_changes = []


searched = []
// see if any of the files match the error logs.
changes.each { item ->
found = false
item.paths.each { path ->
if(!found) {

m = fname_ptn.matcher(path.value)


if(m != null && !searched.contains(m[0][1])) {
searched << m[0][1]
error_lines.each { el ->
if(el.toLowerCase() =~ m[0][1].toLowerCase() && !found) {
found=true
breakage_changes << [m[0][1], item]
}
}
}
}
}
}

// Find the OS level target that failed
failure_patterns = [Pattern.compile(/Target
'((compile|staging|packaging|distribution)-(windows|java|aix|hpux|sun|linux))'
failed/,Pattern.MULTILINE),Pattern.compile(/Cannot execute
'((compile|staging|packaging|distribution)-(windows|java|aix|hpux|sun|linux))'/,Pattern.MULTILINE)]
failure_sets = []

log_file.readLines().each { line ->
failure_patterns.each { ptn ->


m = ptn.matcher(line)
while (m.find()) {

failure_sets << m.group(1)
}
}
}

I am gettting the following error when i am executing the script.


Total time: 1 minute 51 seconds
Email was triggered for: Failure
There are 1 triggered emails.
Sending email for trigger: Failure

Caused by: groovy.lang.GroovyRuntimeException: Failed to parse template
script (your template may contain an error or be trying to use expressions
not currently supported): startup failed, SimpleTemplateScript104.groovy:
112: unexpected token: s @ line 112, column 27.
1 error

at
groovy.text.SimpleTemplateEngine.createTemplate(SimpleTemplateEngine.java:75)
at groovy.text.TemplateEngine.createTemplate(TemplateEngine.java:41)
at
hudson.plugins.emailext.plugins.ContentBuilder.transformUsingScript(ContentBuilder.java:203)


... 14 more
Finished: FAILURE

Thanks.
--
View this message in context: http://groovy.329449.n5.nabble.com/Regex-to-read-the-second-line-tp3299395p3303767.html


Sent from the groovy - user mailing list archive at Nabble.com.

---------------------------------------------------------------------

Paul King

unread,
Dec 13, 2010, 4:20:28 PM12/13/10
to us...@groovy.codehaus.org

If you are going to use readLines().each{} then you will be processing the
lines individually, so DOTALL / (?s) or MULTILINE / (?m) don't make any sense.

Cheers, Paul.

> if(m != null&& !searched.contains(m[0][1])) {


> searched<< m[0][1]
> error_lines.each { el ->

> if(el.toLowerCase() =~ m[0][1].toLowerCase()&& !found) {


> found=true
> breakage_changes<< [m[0][1], item]
> }
> }
> }
> }
> }
> }
>
>
> Thanks.

Paul King

unread,
Dec 13, 2010, 4:43:34 PM12/13/10
to us...@groovy.codehaus.org

This second one also suffers the same problem.
Plus, mixing DOTALL and MULTILINE may not help.

Cheers, Paul.

> if(m != null&& !searched.contains(m[0][1])) {


> searched<< m[0][1]
> error_lines.each { el ->

> if(el.toLowerCase() =~ m[0][1].toLowerCase()&& !found) {

buildscm

unread,
Dec 14, 2010, 12:40:44 PM12/14/10
to us...@groovy.codehaus.org

Hi Paul,

I was trying to execute the script standalone.

i wrote the script as follows

#!/usr/bin/env groovy
import java.util.regex.Matcher
import java.util.regex.Pattern

def log_file = new File('log.txt')
def ptn =


Pattern.compile(/(?si)\s*\[exec\]\s+"\/\/'(?:.(?!\s*\[exec\]\s+"\/\/'))*/)
def error_lines = []

log_file.eachMatch(ptn) {
error_lines << it
}
println error_lines

I am getting error

Caught: groovy.lang.MissingMethodException: No signature of method:


java.io.File
.eachMatch() is applicable for argument types: (java.util.regex.Pattern,

regexp$
_run_closure1) values: [(?si)\s*\[exec\]\s+"//'(?:.(?!\s*\[exec\]\s+"//'))*,
reg
exp$_run_closure1@da18ac]
Possible solutions: eachDirMatch(java.lang.Object, groovy.lang.Closure)
at regexp.run(regexp.groovy:9)


--
View this message in context: http://groovy.329449.n5.nabble.com/Regex-to-read-the-second-line-tp3299395p3304964.html


Sent from the groovy - user mailing list archive at Nabble.com.

---------------------------------------------------------------------

Paul King

unread,
Dec 14, 2010, 3:37:35 PM12/14/10
to us...@groovy.codehaus.org

I think you'll just want:

log_file.text.eachMatch(ptn)

instead of:

log_file.eachMatch(ptn)


Cheers, Paul.

On 15/12/2010 3:40 AM, buildscm wrote:
>
> Hi Paul,
>
> I was trying to execute the script standalone.
>
> i wrote the script as follows
>
> #!/usr/bin/env groovy
> import java.util.regex.Matcher
> import java.util.regex.Pattern
>
> def log_file = new File('log.txt')
> def ptn =
> Pattern.compile(/(?si)\s*\[exec\]\s+"\/\/'(?:.(?!\s*\[exec\]\s+"\/\/'))*/)
> def error_lines = []
>
> log_file.eachMatch(ptn) {
> error_lines<< it
> }
> println error_lines
>
> I am getting error
>
> Caught: groovy.lang.MissingMethodException: No signature of method:
> java.io.File
> .eachMatch() is applicable for argument types: (java.util.regex.Pattern,
> regexp$
> _run_closure1) values: [(?si)\s*\[exec\]\s+"//'(?:.(?!\s*\[exec\]\s+"//'))*,
> reg
> exp$_run_closure1@da18ac]
> Possible solutions: eachDirMatch(java.lang.Object, groovy.lang.Closure)
> at regexp.run(regexp.groovy:9)
>
>

buildscm

unread,
Dec 16, 2010, 2:45:18 PM12/16/10
to us...@groovy.codehaus.org

Hi paul,

Thanks for your help.
It worked with the method log_file.text.eachMatch(ptn), i am getting what i
want, but it is giving the extra lines also which are not needed.

The log looks like this


[exec] "//'TEST.BUILD.LNGSRC(APPQFILE)'", line 15524.46: CCN8924 (W)
Cannot pass an argument of non-POD class type
[exec] "eString" through ellipsis.
[exec] !! END OF JES SPOOL FILE !!
[exec] "//'TEST.BUILD.LNGSRC(APPQUEUE)'", line 3050.65: CCN8924 (W)
Cannot pass an argument of non-POD class type
[exec] "eString" through ellipsis.
[exec] "//'TEST.BUILD.LNGSRC(APPQUEUE)'", line 3050.76: CCN8924 (W)
Cannot pass an argument of non-POD class type
[exec] "eString" through ellipsis.
[exec] "//'TEST.BUILD.LNGSRC(BARCODE)'", line 3832.56: CCN5216 (W) An
expression of type "extern "C" void (*)()" cannot
[exec] be converted to type "int (**)(const char *)".
[exec] "//'TEST.BUILD.S6019.LNGSRC(BARCODE)'", line 3847.57: CCN5216
(W) An expression of type "extern "C" void (*)()" cannot
[exec] be converted to type "int (**)(tag_BarCode *&, const char *,

long, short, int, int, int, int &)".

[exec] "//'TEST.BUILD.LNGSRC(BARCODE)'", line 3882.58: CCN5216 (W) An
expression of type "extern "C" void (*)()" cannot
[exec] be converted to type "int (**)()".
[exec] CCN0793(I) Compilation failed for file
//'TEST.BUILD.S6019.LNGSRC(BARCODE)'. Object file not created.

[exec] !! END OF JES SPOOL FILE !!

[exec] Bad rc: 0012 for ZENG1 at submit_job.pl line 252.
[exec]
[exec] C:\build_areas\Ravi_Dialogue_Doors_MVS\build\utilities>exit 9

C:\build\MVS\build\scripts\mvs-build.xml:559: The following error occurred
while executing this line:
C:\build\MVS\build\scripts\mvs-build.xml:313: The following error occurred
while executing this line:
C:\build\MVS\build\scripts\mvs-build.xml:58: exec returned: 9

Total time: 1 minute 16 seconds


Email was triggered for: Failure
There are 1 triggered emails.
Sending email for trigger: Failure


I am getting these extra lines in my output.

C:\build\MVS\build\scripts\mvs-build.xml:559: The following error occurred
while executing this line:
C:\build\MVS\build\scripts\mvs-build.xml:313: The following error occurred
while executing this line:
C:\build\MVS\build\scripts\mvs-build.xml:58: exec returned: 9

Total time: 1 minute 16 seconds


Email was triggered for: Failure
There are 1 triggered emails.
Sending email for trigger: Failure

I want till the end of the last exec.

[exec] "//'TEST.BUILD.LNGSRC(APPQFILE)'", line 15524.46: CCN8924 (W)
Cannot pass an argument of non-POD class type
[exec] "eString" through ellipsis.
[exec] !! END OF JES SPOOL FILE !!
[exec] "//'TEST.BUILD.LNGSRC(APPQUEUE)'", line 3050.65: CCN8924 (W)
Cannot pass an argument of non-POD class type
[exec] "eString" through ellipsis.
[exec] "//'TEST.BUILD.LNGSRC(APPQUEUE)'", line 3050.76: CCN8924 (W)
Cannot pass an argument of non-POD class type
[exec] "eString" through ellipsis.
[exec] "//'TEST.BUILD.LNGSRC(BARCODE)'", line 3832.56: CCN5216 (W) An
expression of type "extern "C" void (*)()" cannot
[exec] be converted to type "int (**)(const char *)".
[exec] "//'TEST.BUILD.S6019.LNGSRC(BARCODE)'", line 3847.57: CCN5216
(W) An expression of type "extern "C" void (*)()" cannot
[exec] be converted to type "int (**)(tag_BarCode *&, const char *,

long, short, int, int, int, int &)".

[exec] "//'TEST.BUILD.LNGSRC(BARCODE)'", line 3882.58: CCN5216 (W) An
expression of type "extern "C" void (*)()" cannot
[exec] be converted to type "int (**)()".
[exec] CCN0793(I) Compilation failed for file
//'TEST.BUILD.S6019.LNGSRC(BARCODE)'. Object file not created.

[exec] !! END OF JES SPOOL FILE !!

[exec] Bad rc: 0012 for ZENG1 at submit_job.pl line 252.
[exec]
[exec] C:\build_areas\Ravi_Dialogue_Doors_MVS\build\utilities>exit 9


Thanks.

--
View this message in context: http://groovy.329449.n5.nabble.com/Regex-to-read-the-second-line-tp3299395p3308463.html


Sent from the groovy - user mailing list archive at Nabble.com.

---------------------------------------------------------------------

Paul King

unread,
Dec 16, 2010, 4:38:15 PM12/16/10
to us...@groovy.codehaus.org

Looks like you now just have a regex puzzle. The earlier one was using
negative lookahead to demarcate when the next log message started.
You should be able to add a blank line into that as an alternative.
Using one of the regex IDE tools will help a lot for that nutting
out the specifics.

Cheers, Paul.

On 17/12/2010 5:45 AM, buildscm wrote:
>
> Hi paul,
>
> Thanks for your help.
> It worked with the method log_file.text.eachMatch(ptn), i am getting what i
> want, but it is giving the extra lines also which are not needed.
>
> The log looks like this
> [exec] "//'TEST.BUILD.LNGSRC(APPQFILE)'", line 15524.46: CCN8924 (W)
> Cannot pass an argument of non-POD class type
> [exec] "eString" through ellipsis.
> [exec] !! END OF JES SPOOL FILE !!
> [exec] "//'TEST.BUILD.LNGSRC(APPQUEUE)'", line 3050.65: CCN8924 (W)
> Cannot pass an argument of non-POD class type
> [exec] "eString" through ellipsis.
> [exec] "//'TEST.BUILD.LNGSRC(APPQUEUE)'", line 3050.76: CCN8924 (W)
> Cannot pass an argument of non-POD class type
> [exec] "eString" through ellipsis.
> [exec] "//'TEST.BUILD.LNGSRC(BARCODE)'", line 3832.56: CCN5216 (W) An
> expression of type "extern "C" void (*)()" cannot
> [exec] be converted to type "int (**)(const char *)".
> [exec] "//'TEST.BUILD.S6019.LNGSRC(BARCODE)'", line 3847.57: CCN5216
> (W) An expression of type "extern "C" void (*)()" cannot
> [exec] be converted to type "int (**)(tag_BarCode *&, const char *,

> long, short, int, int, int, int&)".

> long, short, int, int, int, int&)".


> [exec] "//'TEST.BUILD.LNGSRC(BARCODE)'", line 3882.58: CCN5216 (W) An
> expression of type "extern "C" void (*)()" cannot
> [exec] be converted to type "int (**)()".
> [exec] CCN0793(I) Compilation failed for file
> //'TEST.BUILD.S6019.LNGSRC(BARCODE)'. Object file not created.
> [exec] !! END OF JES SPOOL FILE !!
> [exec] Bad rc: 0012 for ZENG1 at submit_job.pl line 252.
> [exec]
> [exec] C:\build_areas\Ravi_Dialogue_Doors_MVS\build\utilities>exit 9
>
>
> Thanks.
>

buildscm

unread,
Dec 17, 2010, 3:57:23 PM12/17/10
to us...@groovy.codehaus.org

Hi Paul,

This expression (?!\s*\[exec\]\s+"\/\/') is the negative lookahead in the
regex, do i have to replace it with blank line or insert a blank line in
that expression.

I am using regexbuddy, i didn't find blank line token in that.

Thanks.
--
View this message in context: http://groovy.329449.n5.nabble.com/Regex-to-read-the-second-line-tp3299395p3309955.html


Sent from the groovy - user mailing list archive at Nabble.com.

---------------------------------------------------------------------

buildscm

unread,
Jan 3, 2011, 11:15:40 AM1/3/11
to us...@groovy.codehaus.org

Hi Paul,

I hope you had a good vacation, and happy new year.

Can you please suggest on this regex.

Thanks.

--
View this message in context: http://groovy.329449.n5.nabble.com/Regex-to-read-the-second-line-tp3299395p3325886.html

buildscm

unread,
Jan 20, 2011, 2:18:44 PM1/20/11
to us...@groovy.codehaus.org

I finally got it to work.

log_file.text.eachMatch(/(?si)\s*\[exec\]\s+"\/\/'(?:[^\n]|\n\s*\[exec\](?!\s+"\/\/')[^\n]*)*/){
error_lines << it
}

Thanks to all.
--
View this message in context: http://groovy.329449.n5.nabble.com/Regex-to-read-the-second-line-tp3299395p3350199.html

Reply all
Reply to author
Forward
0 new messages