ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
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_

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 []
Sent: Thursday, October 12, 2000 12:34 PM
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.
<?xml version="1.0" ?>
<project name="test" default="dist" basedir=".">
  <target name="dist" >
    <exec dir="." command="dir" os="Windows NT" output="dir.txt" />
error message:
build.xml:4: Error exec: dir CreateProcess: dir error=2
        at java.lang.Win32Process.<init>(Compiled Code)
        at java.lang.Runtime.exec(Compiled Code)
        at java.lang.Runtime.exec(
        at Code)
        at Code)
        at Code)
        at Code)

Total time: 0 seconds


View raw message