Is it possible to count the lines returned in stdout using InstallBuilder's regular expressions?

thanks.

asked 21 Mar '12, 11:49

wildcatz's gravatar image

wildcatz
16141417
accept rate: 0%


You could use the below code:

<setInstallerVariable name="number" value="1"/>
<while>
    <actionList>
        <mathExpression>
           <text>${number} + 1</text>
           <variable>number</variable>
        </mathExpression>
        <setInstallerVariableFromRegEx>
            <name>program_stdout</name>
            <pattern>^[^\n]*\n(.*)</pattern>
            <substitution>\1</substitution>
            <text>${program_stdout}</text>
        </setInstallerVariableFromRegEx>
    </actionList>
    <conditionRuleList>
        <regExMatch>
            <logic>matches</logic>
            <pattern>^[^\n]*\n(.*)</pattern>
            <text>${program_stdout}</text>
        </regExMatch>
    </conditionRuleList>
</while>

Please note that any double backslashes should be converted to single backslashes.

link

answered 21 Mar '12, 12:51

juanjo's gravatar image

juanjo ♦♦
5.8k413
accept rate: 23%

thanks, but that doesn't work for me. I don't get anything.

(21 Mar '12, 13:04) wildcatz

Looks like with double slashes, if never enters the while. I took out one of the double slashes where they occur, and now it never exits.

I've been banging my head against this for a day now - surely this should be easier than this?!

(21 Mar '12, 13:45) wildcatz

really need some help here! Anyone know how this can be done / fixed?

(21 Mar '12, 20:27) wildcatz

Could you paste the sample text you are using? Also, have you removed the double slashes in the while condition too? (They are automatically added by the form, we will investigate how to solve it)

(22 Mar '12, 04:10) juanjo ♦♦

I have updated the XML above and I have verified it to work properly.

(22 Mar '12, 05:14) wojciechka ♦♦

it works with these changes - I must have missed something. Thanks.

(22 Mar '12, 20:48) wildcatz
showing 5 of 6 show all

If you just need that on Unix, you could call wc:

<setInstallerVariableFromScriptOutput>
    <exec>echo</exec>
    <execArgs>"${program_stdout}" | wc -l</execArgs>
    <name>count</name>
</setInstallerVariableFromScriptOutput>
link

answered 22 Mar '12, 04:24

juanjo's gravatar image

juanjo ♦♦
5.8k413
accept rate: 23%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×4
×1

Asked: 21 Mar '12, 11:49

Seen: 1,902 times

Last updated: 22 Mar '12, 20:48