蚂蚁发送是或否

时间:2011-07-21 13:38:21

标签: ant key

我只是处于事物情景中,

我有一个批处理文件,在运行时会要求确认,例如“按y / n”。现在我要使用ant自动化该批处理文件。所以,我的代码看起来像这样

<exec executable="cmd.exe" dir="${base.dir}" >
  <arg line="/c run.bat" />
</exec>

但我不知道如何在运行时将键盘值'y'传递给它 请帮帮我

3 个答案:

答案 0 :(得分:0)

使用input任务?

答案 1 :(得分:0)

使用input任务的inputstring任务和exec参数的组合。

<input
  message="All data is going to be deleted from DB continue (y/n)?"
  validargs="y,n"
  addproperty="do.delete"
/>

<exec
  executable="cmd.exe"
  dir="${base.dir}"
  inputstring="${do.delete}"
>
  <arg line="/c run.bat" />
</exec>

答案 2 :(得分:0)

只需提供/ y输入就像没有蚂蚁一样:

<exec executable="cmd.exe" dir="${base.dir}" >
  <arg line="/c run.bat /y "/>
</exec>

另一种方法是使用inputstring task。

E.g:

<exec executable= "run.bat" failonerror="true" inputstring="Y">
</exec>

然而,在某些情况下,这被证明是不稳定的。