1

我正在尝试cmd.exe /C echo Please write this to a file >> output.txt使用 ant<exec>任务执行。从命令行执行时,此命令可以正常工作。但是在使用 ant 执行时不起作用。这是我想要做的。

 <exec executable="${env.ComSpec}" osfamily="windows">
    <arg value="/C"/>
    <arg value="echo"/>
    <arg value="Please write this to file"/>
    <arg value=">>"/>
    <arg value="output.txt"/>
</exec>

有人可以告诉我哪里出错了吗?

提前感谢您的投入。

4

1 回答 1

1

>>不是cmd.exe您即将执行的参数,而是当前shell

试试exec ant任务的output参数

<exec executable="${env.ComSpec}" osfamily="windows" output="output.txt"> 
  <arg value="/C"/> 
  <arg value="echo"/> 
  <arg value="Please write this to file"/> 
</exec>
于 2012-04-14T12:28:03.520 回答