With the pointer to the <redirector>, I was able to rewrite the task to avoid a 
temp file. However, that introduced a different problem.

When I do this sequence (i.e. *with* a temp file):
CASE 1:
        <exec error="tempfile"...
        <loadfile srcfile="tempfile" property="errors.present"><filterchain>...
        <fail if "errors.present">...
and there are NO errors (i.e. the filterchain that greps for error messages 
left errors.present unset), the fail is not executed. (This is the desired 
behavior.)

However, when I do this (without a temp file):
CASE 2:
        <exec...><redirector 
errorproperty="errors.present"><errorfilterchain>...
        <fail if "errors.present">...
then the fail *is* executed even when there are NO error messages collected by 
the errorfilterchain.

The problem, of course, is that the property is being set (albeit to an empty 
value) which, to ant, means it is true.

So: any way to make CASE 2 behave like CASE 1? Or, failing that, is there anyway to 
examine a property with "higher" resolution, i.e. to notice that it has an 
empty string or a non-empty string?

Here's a concrete example. As shown, two lines contain error messages, so the fail is executed 
showing those two lines. If you delete the "ERR" from both lines, the "fail" is 
still executed.

    <target name="redirect-test">
                <property name="testfile" value="/usr/tmp/test.dat"/>
                <echo file="${testfile}">
line one
ERR line two
line three
line ERR four
                </echo>
                <exec executable="perl" dir=".">
                        <arg line="-ne 'print' ${testfile}"/>
                        <redirector outputproperty="redirector.out">
                                <outputfilterchain>
                                        <linecontains>
                                                <contains value="ERR"/>
                                        </linecontains>
                                </outputfilterchain>
                        </redirector>
                </exec>
                <delete file="${testfile}"/>
                <fail message="[[${redirector.out}]]" if="redirector.out"/>
    </target>



On Mon, 31 Jan 2005 08:17:52 -0800 (PST), Matt Benson <[EMAIL PROTECTED]> wrote:

--- michael sorens <[EMAIL PROTECTED]> wrote:

Is there a way to manipulate the contents of a
multi-line property string as if it were a file?
Right now I collect stderr of an exec to a temp-file
(error="filename") then read the temp-file and
manipulate via filterchain, storing into a property,
[SNIP]
...then deleting the temp-file.

I'm looking for a more elegant solution.

Jan's example on redirector is not quite cut & paste but it should give you the idea. If you can't get it working after reading the manual and playing around for a while let us know.

Thanks,
Matt




__________________________________ Do you Yahoo!? Yahoo! Mail - Easier than ever with enhanced search. Learn more. http://info.mail.yahoo.com/mail_250

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to