Return-Path: Delivered-To: apmail-ant-user-archive@www.apache.org Received: (qmail 29455 invoked from network); 19 Oct 2004 14:44:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 19 Oct 2004 14:44:51 -0000 Received: (qmail 46675 invoked by uid 500); 19 Oct 2004 14:44:10 -0000 Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 46598 invoked by uid 500); 19 Oct 2004 14:44:10 -0000 Mailing-List: contact user-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list user@ant.apache.org Received: (qmail 46561 invoked by uid 99); 19 Oct 2004 14:44:09 -0000 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=EXTRA_MPART_TYPE,HTML_40_50,HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from [209.226.175.54] (HELO tomts10-srv.bellnexxia.net) (209.226.175.54) by apache.org (qpsmtpd/0.28) with ESMTP; Tue, 19 Oct 2004 07:44:08 -0700 Received: from athlon ([64.231.167.220]) by tomts10-srv.bellnexxia.net (InterMail vM.5.01.06.10 201-253-122-130-110-20040306) with SMTP id <20041019144400.GNVG26826.tomts10-srv.bellnexxia.net@athlon> for ; Tue, 19 Oct 2004 10:44:00 -0400 Message-ID: <006d01c4b5ea$1f121530$0d02a8c0@athlon> From: "Rhino" To: "ant-user" Subject: Running Ant from a Windows batch file Date: Tue, 19 Oct 2004 10:44:21 -0400 MIME-Version: 1.0 Content-Type: multipart/related; type="multipart/alternative"; boundary="----=_NextPart_000_0069_01C4B5C8.97CE1A90" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N ------=_NextPart_000_0069_01C4B5C8.97CE1A90 Content-Type: multipart/alternative; boundary="----=_NextPart_001_006A_01C4B5C8.97CE1A90" ------=_NextPart_001_006A_01C4B5C8.97CE1A90 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable I would like to be able to run an Ant (1.6.1) script from a Windows = batch file on XP. Unfortunately, my Ant script contains tasks = and they are messing me up.=20 Here is my batch file, cond3.bat: ------------------------------------ rem Batch file to run an Ant script. rem This variable is the drive that contains the executable program.=20 set progdrive=3Dd: rem This variable sets the path to the script. set Script=3Declipse\workspace\resume\xml rem Get into the directory containing the program. %progdrive% cd %Script% rem This command runs the program. ant -f cond3.xml pause ------------------------------------ This is my Ant script: ------------------------------------ =20 =20 =20 =20 ------------------------------------ So far my script works fine when run from a batch file except that the = command window closes very quickly upon completion of the script and the = user can't see the message generated by the 'end' target, even though I = have a Windows 'pause' command at the end of the batch file. The 'pause' = command works on other batch files I've written so I don't see why it = doesn't in this case. As a workaround, I tried changing the last lines of the batch file to = say: ant -f cond3.xml > cond3.out notepad cond3.out but this doesn't work properly either. In this case, the script starts = fine but the prompts, like "Which server should receive the files? 1. = Foo 2. Bar 3. Test" from the input task don't appear in the command = window so the user doesn't understand what the command window is waiting = for. Does anyone know how I can have my cake and eat it too, in other words = run Ant from a batch file, see the prompts for inputs, and see the = output messages from Ant? Rhino --- rhino1 AT sympatico DOT ca "There are two ways of constructing a software design. One way is to = make it so simple that there are obviously no deficiencies. And the = other way is to make it so complicated that there are no obvious = deficiencies." - C.A.R. Hoare ------=_NextPart_001_006A_01C4B5C8.97CE1A90 Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable
 
I would like to be able to run an Ant (1.6.1) script from a Windows = batch=20 file on XP. Unfortunately, my Ant script contains <input> = tasks and=20 they are messing me up.
 
Here is my batch file, cond3.bat:
------------------------------------
rem Batch file to run an Ant script.
 
rem This variable is the drive that contains the executable = program.=20
set progdrive=3Dd:
 
rem This variable sets the path to the script.
set=20 Script=3Declipse\workspace\resume\xml
 
rem Get into the directory containing the = program.
%progdrive%
cd=20 %Script%
 
rem This command runs the program.
ant -f cond3.xml
 
pause
------------------------------------
 
This is my Ant script:
 
------------------------------------

<?xml version=3D"1.0"?>

<project name=3D"cond3" default=3D"end" basedir=3D".">

<!--=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

Determine which server is the target.

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D-->

<target name=3D"getserver" description=3D"Determine which server = is the=20 target">

<input message=3D"Which server should receive the files? 1. Foo 2. = Bar 3.=20 Test"

validargs=3D"1,2,3"

addproperty=3D"server.choice"

defaultvalue=3D"2"/>

<condition property=3D"servername" value=3D"foo">

<equals arg1=3D"${server.choice}" arg2=3D"1"/>

</condition>

<condition property=3D"servername" value=3D"bar">

<equals arg1=3D"${server.choice}" arg2=3D"2"/>

</condition>

<condition property=3D"servername" value=3D"test">

<equals arg1=3D"${server.choice}" arg2=3D"3"/>

</condition>

</target>

<!--=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

Load the properties file for the appropriate server.

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D-->

<target name=3D"getprops" depends=3D"getserver" description=3D"Get = the=20 appropriate properties file depending on the server which was = chosen">

<property file=3D"server.${servername}.properties"/>

</target>

<!--=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

Get the userid and password for the desired server.

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D-->

<target name=3D"getlogin" depends=3D"getprops" description=3D"Get = userid and=20 password for server.">

<input message=3D"Please supply the userid for the ${server} = server:"=20 addproperty=3D"userid" defaultvalue=3D"dougb"/>

<input message=3D"Please supply the password for the ${server} = server:"=20 addproperty=3D"password" defaultvalue=3D"dougbpw"/>

</target>

<!--=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

Execute the appropriate upload target, depending on which server

was chosen.

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D-->

<target name=3D"upload" depends=3D"getlogin" description=3D"Upload = to the=20 selected server.">

<antcall target=3D"upload-${servername}"/>

</target>

<!--=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

Upload to the 'foo' server.

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D-->

<target name=3D"upload-foo" description=3D"Upload to the foo = server.">

<echo message=3D"Uploading to foo...."/>

<echoproperties prefix=3D"server"/>

</target>

<!--=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

Upload to the 'bar' server.

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D-->

<target name=3D"upload-bar" description=3D"Upload to the bar = server.">

<echo message=3D"Uploading to bar...."/>

<echoproperties prefix=3D"server"/>

</target>

<!--=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

Upload to the 'test' server.

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D-->

<target name=3D"upload-test" description=3D"Upload to the test=20 server.">

<echo message=3D"Uploading to test...."/>

<echoproperties prefix=3D"server"/>

</target>

<!--=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

Display a message to the user.

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D-->

<target name=3D"end" depends=3D"upload" description=3D"Display a=20 message.">

<echo message=3D"Uploads to server ${servername} are = complete."/>

</target>

</project>

------------------------------------
 
So far my script works fine when run from a batch file = except=20 that the command window closes very quickly upon completion of the = script and=20 the user can't see the message generated by the 'end' target, even = though I have=20 a Windows 'pause' command at the end of the batch file. The 'pause' = command=20 works on other batch files I've written so I don't see why it doesn't in = this=20 case.
 
As a workaround, I tried changing the last lines of the batch file = to=20 say:
 
ant -f cond3.xml > cond3.out
notepad cond3.out
 
but this doesn't work properly either. In this case, the script = starts fine=20 but the prompts, like "Which server should receive the files? 1. = Foo 2. Bar=20 3. Test"  from the input task don't appear in the command window so = the=20 user doesn't understand what the command window is waiting for.
 
Does anyone know how I can have my cake and eat it too, in other = words run=20 Ant from a batch file, see the prompts for inputs, and see the output = messages=20 from Ant?
 
 
Rhino
---
rhino1 AT sympatico DOT ca
"There are two ways = of=20 constructing a software design. One way is to make it so simple that = there are=20 obviously no deficiencies. And the other way is to make it so = complicated that=20 there are no obvious deficiencies." - C.A.R. Hoare
------=_NextPart_001_006A_01C4B5C8.97CE1A90-- ------=_NextPart_000_0069_01C4B5C8.97CE1A90--