ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fred Welland <>
Subject Re: Difficulty calling a batch file on windows with <exec>- requires use of '.bat' extension
Date Thu, 22 Mar 2001 12:26:40 GMT
I have the exact same problem!   In my case, thou, I was able to
correctly call iasdeploy (on windows using the bat file) when I ran ANT
from a vanilla MSDos/Command prompt.  But 'iasdeploy' failed when I call
ANT from an MKS tools KSH window.  If you are using a different shell
than cmd.exe maybe you are haveing the same problem as me.  (FYI:  ANT
1.3, JDK 1.3, WinNT sp5).

What I did was:

1)  To allow for small workstation variations we 'load' some key
properties from properties file (see the property task for details).

2)  At the very top/global of my build xml file I do:  <property
file="mybuild.props"/>  Which loads the props from an external prop

3)  I made a 'global' property like this  <property name "deploycmd"
value="iasdeploy"/>  - that is the property declaration is just under my
project declaration element (i.e. top of my build.xml not in any
target).  I put this line sometime just after loading the properties

4)  When you put a property in the props file, in this case,
"deploycmd=iasdeploy.bat"  it overrides the property declaration in the
build.xml file.

5)  When I do exec tasks I use ${deploycmd} as my executable in my
build.xml file.

6)  When I am on Windows I add the override deploycmd to my props file.
When I solaris, I don't (and it uses the value declared in the build

Doing this I have been able to keep my build files the same but allow
for these little differences.  The workaround with the 'os' attribute is
OK too - I opted out of this, since I didn't want to maintain multiple
execs command in case I need to change iasdeploy args or the like.

Just another option.

Fred Welland
Intelix Inc.

Deepak Balakrishna wrote:

> Hi.
> Summary
> -------
> I am uable to call a Windows batch script (say
> test.bat) from ANT by leaving out the '.bat' extension
> Detail
> ------
> I am trying to create a common build.xml file for both
> Windows NT and for Solaris. I have a problem with one
> of my targets requiring a workaround.
> <target name="install_ear">
>     <exec executable="${ias.bin}/iasdeploy">
>       <arg line="${ear}"/>
>     </exec>
> </target>
> I have a program iasdeploy.bat on Windows NT and
> iasdeploy on Solaris which should get invoked from
> this target. However, that does not happen. On
> Windows, I get the following error which requires me
> to explicity use 'iasdeploy.bat' as my executable
> target
> Error
> ----
> D:\iPlanet\ias-samples\helloworld\src\build.xml:175:
> Execute failed: CreateProcess:
> d:\iplanet\ias6\ias/bin/j2eeappreg ../helloworld.ear
> error=2
> CreateProcess:
> d:\iplanet\ias6\ias/bin/j2eeappreg ../helloworld.ear
> error=2
>         at java.lang.Win32Process.create(Native Method)
>         at
> java.lang.Win32Process.<init>(
> ... etc ...
> Workaround
> -----------
> The workaround involves using the "os" attribute. Is
> there any way to avoid this and have one common
> section that will work on all OS?
> <target name="install_ear">
> <exec executable="${ias.bin}/iasdeploy" os="SunOS">
> <arg line="${ear}"/>
> </exec>
> <exec executable="${ias.bin}/iasdeploy.bat"
> os="Windows NT">
> <arg line="${ear}"/>
> </exec>
> </target>
> __________________________________________________
> Do You Yahoo!?
> Get email at your own domain with Yahoo! Mail.

View raw message