You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Deepak Balakrishna <gb...@yahoo.com> on 2001/03/21 21:31:56 UTC
Difficulty calling a batch file on windows with - requires use of '.bat' extension
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
----
BUILD FAILED
D:\iPlanet\ias-samples\helloworld\src\build.xml:175:
Execute failed: java.io.IOException: CreateProcess:
d:\iplanet\ias6\ias/bin/j2eeappreg ../helloworld.ear
error=2
java.io.IOException: CreateProcess:
d:\iplanet\ias6\ias/bin/j2eeappreg ../helloworld.ear
error=2
at java.lang.Win32Process.create(Native Method)
at
java.lang.Win32Process.<init>(Win32Process.java:64)
... 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.
http://personal.mail.yahoo.com/
Re: Difficulty calling a batch file on windows with - requires use of '.bat' extension
Posted by Diane Holt <ho...@yahoo.com>.
> Deepak Balakrishna wrote:
>
> I am uable to call a Windows batch script (say
> test.bat) from ANT by leaving out the '.bat' extension
How about setting a "bat" property only on your Windows machines (ie.,
bat=".bat"), then referencing the script as "test${bat}"? On machines
that don't have ${bat} defined, it should resolve to just "test". (Sorry
I can't test it to be sure at the moment, but it seems like it should
work.)
Diane
=====
(holtdl@yahoo.com)
__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/
Re: Difficulty calling a batch file on windows with - requires use
of '.bat' extension
Posted by Bevan Arps <be...@actfs.co.nz>.
Deepak Balakrishna wrote:
> I am uable to call a Windows batch script (say
> test.bat) from ANT by leaving out the '.bat' extension
The ability to leave out .exe or .com actually originates with the
Windows API call "CreateProcess".
I don't believe that Ant does anything except pass through the
executable attribute straight through the JavaAPI to Windows.
How about calling the script iasdeploy.bat on all systems (Solaris
included)? <grin>
Otherwise, I don't have any suggestions.
Cheers,
Bevan.
_______________________________________________________________________
Bevan Arps, OO Analyst email: bevan.arps@actfs.co.nz
ACT Financial Systems "Programming is an Art Form that Fights Back"
***********************************************************************
This communication is confidential to ACT Financial Systems (Asia
Pacific) and is intended for use only by the addressee. The views
and opinions expressed in this email are the senders own and do not
represent the views and opinions of ACT Financial Systems (Asia
Pacific).
***********************************************************************
Re: Difficulty calling a batch file on windows with - requires use
of '.bat' extension
Posted by Fred Welland <fw...@intelixinc.com>.
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
file.
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
file.
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
file).
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
> ----
> BUILD FAILED
>
> D:\iPlanet\ias-samples\helloworld\src\build.xml:175:
> Execute failed: java.io.IOException: CreateProcess:
> d:\iplanet\ias6\ias/bin/j2eeappreg ../helloworld.ear
> error=2
> java.io.IOException: CreateProcess:
> d:\iplanet\ias6\ias/bin/j2eeappreg ../helloworld.ear
> error=2
> at java.lang.Win32Process.create(Native Method)
> at
> java.lang.Win32Process.<init>(Win32Process.java:64)
> ... 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.
> http://personal.mail.yahoo.com/
Re: Difficulty calling a batch file on windows with -
requires use of '.bat' extension
Posted by Peter Donald <do...@apache.org>.
At 12:31 21/3/01 -0800, 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
Thats expected behaviour ;)
Cheers,
Pete
*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof." |
| - John Kenneth Galbraith |
*-----------------------------------------------------*