You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Redondo Gallardo, Raul Maria" <rm...@eservicios.indra.es> on 2009/08/04 11:37:52 UTC

Check if exist a file and then run or not a target

Hello,

 

I'm trying to do with ANT anything like:

 

            If exist a file (file.txt)

                        Exec file.bat

            End if

 

But I don't get it. Is it possible to do this with ANT?

 

Thank you very much.

 

Best regards,

 

Raúl María Redondo Gallardo

 Dpto. transporte y Tráfico

<http://www.indra.es/> 

 

C/ Mar Egeo, 4

Pol. Ind. San Fernando

San Fernando de Henares

28830 - Madrid (ESPAÑA)
Tel:  +34-91-626.92.21

Fax: +34-91.626.88.68

rmredondo@eservicios.indra.es

www.indra.es

 


RE: Check if exist a file and then run or not a target

Posted by Felix Dorner <FD...@zed.com>.
Maybe you want, although it's not really the same...?

<exec failifexecutionfails="false">
...

The other way would be to use ant-contrib's if. Which I think is ugly.
I'm trying to do with ANT anything like:

            If exist a file (file.txt)
                        Exec file.bat
            End if



Re: Check if exist a file and then run or not a target

Posted by Sushim Saini <su...@gmail.com>.
ya my mistake it should be like
if="fileExist", not if="checkForExist"

Thanks to correct me



On Tue, Aug 4, 2009 at 3:45 PM, Michael George <md...@cs.cornell.edu>wrote:

> Redondo Gallardo, Raul Maria wrote:
>
>> Thank you very much,
>>
>> I'll try it now, this seems be a good form to do this.
>>
>> Thank you very much.
>>
>> Best regards
>>
>> -----Mensaje original-----
>> De: Sushim Saini [mailto:sushimsaini@gmail.com] Enviado el: martes, 04 de
>> agosto de 2009 11:46
>> Para: Ant Users List
>> Asunto: Re: Check if exist a file and then run or not a target
>>
>> HI u can try like that
>>  <target name="checkForExist">
>>        <available file="${dir}/file.txt" property="fileExist"/>
>>    </target>
>>  <target name="invokeTargetIfExist" depends="checkForExist"
>> if="checkForExist">
>>        Exec file.bat
>> </target>
>>
>>
> I think you want: if="fileExist", not if="checkForExist"
>
> --Mike
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>


-- 
Sushim Saini
09920547761

Re: Check if exist a file and then run or not a target

Posted by Michael George <md...@cs.cornell.edu>.
Redondo Gallardo, Raul Maria wrote:
> Thank you very much,
>
> I'll try it now, this seems be a good form to do this.
>
> Thank you very much.
>
> Best regards
>
> -----Mensaje original-----
> De: Sushim Saini [mailto:sushimsaini@gmail.com] 
> Enviado el: martes, 04 de agosto de 2009 11:46
> Para: Ant Users List
> Asunto: Re: Check if exist a file and then run or not a target
>
> HI u can try like that
>  <target name="checkForExist">
>         <available file="${dir}/file.txt" property="fileExist"/>
>     </target>
>  <target name="invokeTargetIfExist" depends="checkForExist"
> if="checkForExist">
>         Exec file.bat
> </target>
>   
I think you want: if="fileExist", not if="checkForExist"

--Mike

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


RE: Check if exist a file and then run or not a target

Posted by "Redondo Gallardo, Raul Maria" <rm...@eservicios.indra.es>.
Thank you very much,

I'll try it now, this seems be a good form to do this.

Thank you very much.

Best regards

-----Mensaje original-----
De: Sushim Saini [mailto:sushimsaini@gmail.com] 
Enviado el: martes, 04 de agosto de 2009 11:46
Para: Ant Users List
Asunto: Re: Check if exist a file and then run or not a target

HI u can try like that
 <target name="checkForExist">
        <available file="${dir}/file.txt" property="fileExist"/>
    </target>
 <target name="invokeTargetIfExist" depends="checkForExist"
if="checkForExist">
        Exec file.bat
</target>

hope will helpfull for u

Sushim

On Tue, Aug 4, 2009 at 3:07 PM, Redondo Gallardo, Raul Maria <
rmredondo@eservicios.indra.es> wrote:

>  Hello,
>
>
>
> I'm trying to do with ANT anything like:
>
>
>
>             If exist a file (file.txt)
>
>                         Exec file.bat
>
>             End if
>
>
>
> But I don't get it. Is it possible to do this with ANT?
>
>
>
> Thank you very much.
>
>
>
> Best regards,
>
>
>
> *Raúl María Redondo Gallardo*
>
> * Dpto. transporte y Tráfico*
>
> * <http://www.indra.es/>*
>
> **
>
> *C/ Mar Egeo, 4*
>
> *Pol. Ind. San Fernando*
>
> *San Fernando de Henares*
>
> *28830 - Madrid (ESPAÑA)
> Tel:  +34-91-626.92.21*
>
> *Fax: +34-91.626.88.68*
>
> rmredondo@eservicios.indra.es
>
> *www.indra.es*
>
>
>



-- 
Sushim Saini
09920547761

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


Re: Check if exist a file and then run or not a target

Posted by Sushim Saini <su...@gmail.com>.
HI u can try like that
 <target name="checkForExist">
        <available file="${dir}/file.txt" property="fileExist"/>
    </target>
 <target name="invokeTargetIfExist" depends="checkForExist"
if="checkForExist">
        Exec file.bat
</target>

hope will helpfull for u

Sushim

On Tue, Aug 4, 2009 at 3:07 PM, Redondo Gallardo, Raul Maria <
rmredondo@eservicios.indra.es> wrote:

>  Hello,
>
>
>
> I’m trying to do with ANT anything like:
>
>
>
>             If exist a file (file.txt)
>
>                         Exec file.bat
>
>             End if
>
>
>
> But I don’t get it. Is it possible to do this with ANT?
>
>
>
> Thank you very much.
>
>
>
> Best regards,
>
>
>
> *Raúl María Redondo Gallardo*
>
> * Dpto. transporte y Tráfico*
>
> * <http://www.indra.es/>*
>
> **
>
> *C/ Mar Egeo, 4*
>
> *Pol. Ind. San Fernando*
>
> *San Fernando de Henares*
>
> *28830 - Madrid (ESPAÑA)
> Tel:  +34-91-626.92.21*
>
> *Fax: +34-91.626.88.68*
>
> rmredondo@eservicios.indra.es
>
> *www.indra.es*
>
>
>



-- 
Sushim Saini
09920547761