You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by shi chuan <sh...@gmail.com> on 2011/05/12 20:45:02 UTC
ant execute Windows del command
Hi guys, I am trying to apply a task using Windows executable 'del' to
delete files, the reason I don't use <delete> is because it will delete even
if things are up to date.
However this runs into an error: cannot run program 'del'...error=2
<apply executable="del" dest="./abc/" osfamily="windows"
addsourcefile="false">
Is there anything I can do to the above command to make it work under
Windows?
thanks
Shi
Re: ant execute Windows del command
Posted by shi chuan <sh...@gmail.com>.
thanks a lot! it works like a charm!
On Fri, May 13, 2011 at 3:44 AM, Dominique Devienne <dd...@gmail.com>wrote:
> On Thu, May 12, 2011 at 2:35 PM, shi chuan <sh...@gmail.com> wrote:
> > thanks for the quick reply, now i tried the one below, still no luck,
> > anything else that could be wrong?
>
> My bad, it's /c, not -c. --DD
>
> D:\>touch foo
> D:\>touch bar
> D:\>dir /B foo bar
> foo
> bar
> D:\>cmd /nologo /c del foo bar
> D:\>dir /B foo bar
> File Not Found
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
Re: ant execute Windows del command
Posted by Dominique Devienne <dd...@gmail.com>.
On Thu, May 12, 2011 at 2:35 PM, shi chuan <sh...@gmail.com> wrote:
> thanks for the quick reply, now i tried the one below, still no luck,
> anything else that could be wrong?
My bad, it's /c, not -c. --DD
D:\>touch foo
D:\>touch bar
D:\>dir /B foo bar
foo
bar
D:\>cmd /nologo /c del foo bar
D:\>dir /B foo bar
File Not Found
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: ant execute Windows del command
Posted by shi chuan <sh...@gmail.com>.
thanks for the quick reply, now i tried the one below, still no luck,
anything else that could be wrong?
<apply executable="cmd" dest="./${dir.publish}/${dir.images}/"
osfamily="windows" addsourcefile="false">
<arg value="-c"/>
<arg value="del"/>
<fileset dir="./${dir.source}/${dir.images}/" includes="*.png"/>
<targetfile/>
<mapper type="identity"/>
</apply>
On Fri, May 13, 2011 at 3:30 AM, Dominique Devienne <dd...@gmail.com>wrote:
> On Thu, May 12, 2011 at 2:17 PM, shi chuan <sh...@gmail.com> wrote:
> > <arg value="-c del"/>
>
> That's a single <arg> of name "-c del", not two args "-c" and "del".
>
> Use either line="-c del" or two <arg value>. --DD
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
Re: ant execute Windows del command
Posted by Dominique Devienne <dd...@gmail.com>.
On Thu, May 12, 2011 at 2:17 PM, shi chuan <sh...@gmail.com> wrote:
> <arg value="-c del"/>
That's a single <arg> of name "-c del", not two args "-c" and "del".
Use either line="-c del" or two <arg value>. --DD
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: ant execute Windows del command
Posted by shi chuan <sh...@gmail.com>.
Now I am trying to use the following, it seems the error message is gone,
but the file is not deleted:
<apply executable="cmd" dest="./${dir.publish}/${dir.images}/"
osfamily="windows" addsourcefile="false">
<fileset dir="./${dir.source}/${dir.images}/" includes="*.png"/>
<arg value="-c del"/>
<targetfile/>
<mapper type="identity"/>
</apply>
On Fri, May 13, 2011 at 2:55 AM, Dominique Devienne <dd...@gmail.com>wrote:
> On Thu, May 12, 2011 at 1:45 PM, shi chuan <sh...@gmail.com> wrote:
> > Hi guys, I am trying to apply a task using Windows executable 'del' to
> > delete files, the reason I don't use <delete> is because it will delete
> even
> > if things are up to date.
> > However this runs into an error: cannot run program 'del'...error=2
> >
> > <apply executable="del" dest="./abc/" osfamily="windows"
> > addsourcefile="false">
>
> That's because 'del' is not a program, but a builtin 'cmd.exe' "Shell".
>
> That's similar to why http://ant.apache.org/manual/Tasks/exec.html
> uses 'cmd -c foo.bat'
>
> Thus try <apply executable="cmd" ...> and add "-c del" as a command
> line arg. --DD
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
Re: ant execute Windows del command
Posted by Dominique Devienne <dd...@gmail.com>.
On Thu, May 12, 2011 at 1:45 PM, shi chuan <sh...@gmail.com> wrote:
> Hi guys, I am trying to apply a task using Windows executable 'del' to
> delete files, the reason I don't use <delete> is because it will delete even
> if things are up to date.
> However this runs into an error: cannot run program 'del'...error=2
>
> <apply executable="del" dest="./abc/" osfamily="windows"
> addsourcefile="false">
That's because 'del' is not a program, but a builtin 'cmd.exe' "Shell".
That's similar to why http://ant.apache.org/manual/Tasks/exec.html
uses 'cmd -c foo.bat'
Thus try <apply executable="cmd" ...> and add "-c del" as a command
line arg. --DD
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org