You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Ivar Bratberg <Iv...@fast.no> on 2008/08/19 14:22:21 UTC

variables or a counter ?

Hi, 
I have the following problem I try to solve in ant.
I should check a www server for a certain result each minute.
I should keep on checking until a desired result is given ( the file
downloaded should exceed a certain limit )
In addition it should have a kind of timeout so it it will return if it
has tried too many times.


I I have made a ant macro which calls itself recursively since there is
no <while> task
I have also access to a <if> task so I manage to check if I have got the
wanted result


But as mentioned I would like to have a timeout, by counting up a
parameter which is given to the recursive macro.
Is this possible ?
I have not seen any <add> or <math> task.

Do some of you have better suggestions for solving this ?
Note, I cannot use <waitfor> task, because I have to check not only for
error code on the response, but the text itself( I manage whith checking
the length of the file downloaded >

To summarize my questions:

- Can I add to variables/properties and but the result in a third
property ?
- Is there a better way than recursive macro to achieve the effect of
<while> looping ?

Ivar



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: AW: variables or a counter ?

Posted by Olivier Gies <ol...@bull.net>.
To do what you want to do, I would use Ant's <waitfor> in combination 
with <resourcecount> condition returning the number of files with a size 
over the limit you want to set in a fileset including only the file 
being downloaded.

I have used this method with great efficiency for similar tasks (waiting 
for a server to start/fail by looking up the server log for a certain 
start-up string)

BR

*Olivier Gies*

*Delivery Manager
Customs & Tax Software Engineering Center
Bull, Architect of an Open World ^TM
Phone: +86 (10) 65978001 - Ext 555 *

*www.bull.com <http://www.bull.com/>*

*This e-mail contains material that is confidential for the sole use of
the intended recipient. Any review, reliance or distribution by others
or forwarding without express permission is strictly prohibited. If you
are not the intended recipient, please contact the sender and delete all
copies.*



-------- Original Message  --------
Subject: AW: variables or a counter ?
From: Knuplesch, Juergen <Ju...@icongmbh.de>
To: Ant Users List <us...@ant.apache.org>
Date: 19/08/2008 21:30

> Antcontrib has a Math Task to add and variables that can change their value.
> It also has a for task.
> 
> http://ant-contrib.sourceforge.net/tasks/tasks/index.html 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


AW: variables or a counter ?

Posted by "Knuplesch, Juergen" <Ju...@icongmbh.de>.
Antcontrib has a Math Task to add and variables that can change their value.
It also has a for task.

http://ant-contrib.sourceforge.net/tasks/tasks/index.html 


-- 
Jürgen Knuplesch

-----Ursprüngliche Nachricht-----
Von: Ivar Bratberg [mailto:Ivar.Bratberg@fast.no] 
Gesendet: Dienstag, 19. August 2008 14:22
An: Ant Users List
Betreff: variables or a counter ?

Hi,
I have the following problem I try to solve in ant.
I should check a www server for a certain result each minute.
I should keep on checking until a desired result is given ( the file downloaded should exceed a certain limit ) In addition it should have a kind of timeout so it it will return if it has tried too many times.


I I have made a ant macro which calls itself recursively since there is
no <while> task
I have also access to a <if> task so I manage to check if I have got the
wanted result


But as mentioned I would like to have a timeout, by counting up a
parameter which is given to the recursive macro.
Is this possible ?
I have not seen any <add> or <math> task.

Do some of you have better suggestions for solving this ?
Note, I cannot use <waitfor> task, because I have to check not only for
error code on the response, but the text itself( I manage whith checking
the length of the file downloaded >

To summarize my questions:

- Can I add to variables/properties and but the result in a third
property ?
- Is there a better way than recursive macro to achieve the effect of
<while> looping ?

Ivar



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: variables or a counter ?

Posted by Steve Loughran <st...@apache.org>.
Ivar Bratberg wrote:
> Hi, 
> I have the following problem I try to solve in ant.
> I should check a www server for a certain result each minute.
> I should keep on checking until a desired result is given ( the file
> downloaded should exceed a certain limit )
> In addition it should have a kind of timeout so it it will return if it
> has tried too many times.


> Do some of you have better suggestions for solving this ?
> Note, I cannot use <waitfor> task, because I have to check not only for
> error code on the response, but the text itself( I manage whith checking
> the length of the file downloaded >

Actually, it sounds like you can use <waitfor>, just with an extended 
condition. I do something similar at work where we actually run regexp 
patterns over the response and wait for a specific pattern coming back.

-- 
Steve Loughran                  http://www.1060.org/blogxter/publish/5
Author: Ant in Action           http://antbook.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: variables or a counter ?

Posted by "Scot P. Floess" <fl...@mindspring.com>.
I totally disagree.  Ant can also be used as a scripting 
language...especially when using add-ons like Ant-Contrib.  I definitely 
use it to perform more than just builds.  Its fairly wide-open in what one 
can do if you ask me.

On Tue, 19 Aug 2008, Evgeny wrote:

> IMHO ant is not a suitable tool for the task you need, ant is a build tool -
> not a scripting language.
> In your case it would be much better to use some other language, like
> ruby/python/bash/perl/whatever ... than to use ant.
>
> On Tue, Aug 19, 2008 at 4:48 PM, Scot P. Floess <fl...@mindspring.com>wrote:
>
>> Just a note, be careful about recursively calling a macro...  You will
>> eventually get a stack overflow.  I did something like this with a simulated
>> for-loop using Ant Contrib's Math task.  I found after around 300 - 400
>> iterations I'd get a stack overflow...
>>
>>
>> On Tue, 19 Aug 2008, Ivar Bratberg wrote:
>>
>>  Hi,
>>> I have the following problem I try to solve in ant.
>>> I should check a www server for a certain result each minute.
>>> I should keep on checking until a desired result is given ( the file
>>> downloaded should exceed a certain limit )
>>> In addition it should have a kind of timeout so it it will return if it
>>> has tried too many times.
>>>
>>>
>>> I I have made a ant macro which calls itself recursively since there is
>>> no <while> task
>>> I have also access to a <if> task so I manage to check if I have got the
>>> wanted result
>>>
>>>
>>> But as mentioned I would like to have a timeout, by counting up a
>>> parameter which is given to the recursive macro.
>>> Is this possible ?
>>> I have not seen any <add> or <math> task.
>>>
>>> Do some of you have better suggestions for solving this ?
>>> Note, I cannot use <waitfor> task, because I have to check not only for
>>> error code on the response, but the text itself( I manage whith checking
>>> the length of the file downloaded >
>>>
>>> To summarize my questions:
>>>
>>> - Can I add to variables/properties and but the result in a third
>>> property ?
>>> - Is there a better way than recursive macro to achieve the effect of
>>> <while> looping ?
>>>
>>> Ivar
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>> For additional commands, e-mail: user-help@ant.apache.org
>>>
>>>
>>>
>> Scot P. Floess
>> 27 Lake Royale
>> Louisburg, NC  27549
>>
>> 252-478-8087 (Home)
>> 919-754-4592 (Work)
>>
>> Chief Architect JPlate   http://sourceforge.net/projects/jplate
>> Chief Architect JavaPIM  http://sourceforge.net/projects/javapim
>>
>> Architect Keros          http://sourceforge.net/projects/keros
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>>
>>
>

Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087 (Home)
919-754-4592 (Work)

Chief Architect JPlate   http://sourceforge.net/projects/jplate
Chief Architect JavaPIM  http://sourceforge.net/projects/javapim

Architect Keros          http://sourceforge.net/projects/keros

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: variables or a counter ?

Posted by Evgeny <ev...@gmail.com>.
IMHO ant is not a suitable tool for the task you need, ant is a build tool -
not a scripting language.
In your case it would be much better to use some other language, like
ruby/python/bash/perl/whatever ... than to use ant.

On Tue, Aug 19, 2008 at 4:48 PM, Scot P. Floess <fl...@mindspring.com>wrote:

> Just a note, be careful about recursively calling a macro...  You will
> eventually get a stack overflow.  I did something like this with a simulated
> for-loop using Ant Contrib's Math task.  I found after around 300 - 400
> iterations I'd get a stack overflow...
>
>
> On Tue, 19 Aug 2008, Ivar Bratberg wrote:
>
>  Hi,
>> I have the following problem I try to solve in ant.
>> I should check a www server for a certain result each minute.
>> I should keep on checking until a desired result is given ( the file
>> downloaded should exceed a certain limit )
>> In addition it should have a kind of timeout so it it will return if it
>> has tried too many times.
>>
>>
>> I I have made a ant macro which calls itself recursively since there is
>> no <while> task
>> I have also access to a <if> task so I manage to check if I have got the
>> wanted result
>>
>>
>> But as mentioned I would like to have a timeout, by counting up a
>> parameter which is given to the recursive macro.
>> Is this possible ?
>> I have not seen any <add> or <math> task.
>>
>> Do some of you have better suggestions for solving this ?
>> Note, I cannot use <waitfor> task, because I have to check not only for
>> error code on the response, but the text itself( I manage whith checking
>> the length of the file downloaded >
>>
>> To summarize my questions:
>>
>> - Can I add to variables/properties and but the result in a third
>> property ?
>> - Is there a better way than recursive macro to achieve the effect of
>> <while> looping ?
>>
>> Ivar
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>>
>>
>>
> Scot P. Floess
> 27 Lake Royale
> Louisburg, NC  27549
>
> 252-478-8087 (Home)
> 919-754-4592 (Work)
>
> Chief Architect JPlate   http://sourceforge.net/projects/jplate
> Chief Architect JavaPIM  http://sourceforge.net/projects/javapim
>
> Architect Keros          http://sourceforge.net/projects/keros
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

Re: variables or a counter ?

Posted by "Scot P. Floess" <fl...@mindspring.com>.
Just a note, be careful about recursively calling a macro...  You will 
eventually get a stack overflow.  I did something like this with a 
simulated for-loop using Ant Contrib's Math task.  I found after around 
300 - 400 iterations I'd get a stack overflow...

On Tue, 19 Aug 2008, Ivar Bratberg wrote:

> Hi,
> I have the following problem I try to solve in ant.
> I should check a www server for a certain result each minute.
> I should keep on checking until a desired result is given ( the file
> downloaded should exceed a certain limit )
> In addition it should have a kind of timeout so it it will return if it
> has tried too many times.
>
>
> I I have made a ant macro which calls itself recursively since there is
> no <while> task
> I have also access to a <if> task so I manage to check if I have got the
> wanted result
>
>
> But as mentioned I would like to have a timeout, by counting up a
> parameter which is given to the recursive macro.
> Is this possible ?
> I have not seen any <add> or <math> task.
>
> Do some of you have better suggestions for solving this ?
> Note, I cannot use <waitfor> task, because I have to check not only for
> error code on the response, but the text itself( I manage whith checking
> the length of the file downloaded >
>
> To summarize my questions:
>
> - Can I add to variables/properties and but the result in a third
> property ?
> - Is there a better way than recursive macro to achieve the effect of
> <while> looping ?
>
> Ivar
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087 (Home)
919-754-4592 (Work)

Chief Architect JPlate   http://sourceforge.net/projects/jplate
Chief Architect JavaPIM  http://sourceforge.net/projects/javapim

Architect Keros          http://sourceforge.net/projects/keros

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org