ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwald...@us.britannica.com
Subject RE: a possible bug in Exec ?
Date Thu, 12 Oct 2000 19:06:25 GMT
"dir" is a command of the DOS shell (just like "ls" is usually defined
within your Unix shell), not of the operating system itself.  If you want to
do a "dir", one way to do it is to create a batch file than runs it:

_file: foo.bat_
dir

and run 

<exec dir="." command="foo.bat" os="Windows NT" output="dir.txt" />

You could also create a generic batch shell, like:

_file: dynamic.bat_
%1 %2 %3 %4 %5 %6 %7 %8 %9

and use it for arbitrary DOS commands:

<exec dir="." command="dynamic.bat dir /w" os="Windows NT" output="dir.txt"
/>

This isn't a bug in Ant, or even java.lang.Runtime.exec(), but rather a
"feature" of the relation between operating systems and shells.


-----Original Message-----
From: Andy XueWen Qin [mailto:aqin@cisco.com]
Sent: Thursday, October 12, 2000 12:34 PM
To: ant-user@jakarta.apache.org
Subject: a possible bug in Exec ?


I'm trying to use exec task on Windows NT, it's very simple
test build.xml file, but giving out a strange error. When I
change the dir="." to dir="..", it works fine, any ideas ?
The ant version I'm using is Ant1.1.
-----------
build.xml
------------
<?xml version="1.0" ?>
<project name="test" default="dist" basedir=".">
  <target name="dist" >
    <exec dir="." command="dir" os="Windows NT" output="dir.txt" />
  </target>
</project>
------------
error message:
-----------
build.xml:4: Error exec: dir
java.io.IOException: CreateProcess: dir error=2
        at java.lang.Win32Process.<init>(Compiled Code)
        at java.lang.Runtime.exec(Compiled Code)
        at java.lang.Runtime.exec(Runtime.java:137)
        at org.apache.tools.ant.taskdefs.Exec.run(Exec.java:124)
        at org.apache.tools.ant.taskdefs.Exec.execute(Exec.java:77)
        at org.apache.tools.ant.Target.execute(Compiled Code)
        at org.apache.tools.ant.Project.runTarget(Project.java:717)
        at org.apache.tools.ant.Project.executeTarget(Compiled Code)
        at org.apache.tools.ant.Project.executeTargets(Compiled Code)
        at org.apache.tools.ant.Main.runBuild(Compiled Code)
        at org.apache.tools.ant.Main.main(Main.java:107)

Total time: 0 seconds
------------------------

Thanks
/andy

Mime
View raw message