0

I have an ant script which runs an interactive (that requires 2 user inputs) dos batch file using exec task. I tried using attributes 'inputstring' (having 2 inputs (space in between, & in between)) and 'input' (file having 2 entries)

Only the first input is provided by exec task to the batch file, the script waits indefinitely for the second input.

is there a way to provide multiple inputs through exec task (or) is there a dos command to provide inputs for an interactive mode batch?

Snippet 1:

<exec dir="F:/upgrade" executable="cmd.exe" failonerror="true" output="upgrade.out" inputstring ="no&amp;&amp;yes">                     
    <arg line="/c upgrade process F:/script"/>
</exec>

Snippet 2:

<exec dir="F:/upgrade" executable="cmd.exe" failonerror="true" output="upgrade.out" input ="upgrade.input">                     
    <arg line="/c upgrade process F:/script"/>
</exec>

Input File content

no
yes
4

1 回答 1

0

诀窍是将“ENTER”的按下模拟为单个输入。“Enter”的代码是许多语言中的字符“\n”。它的 XML 编码形式是实体:&#x0A;.

所以这应该可以解决问题:

<exec dir="F:/upgrade" executable="cmd.exe" failonerror="true"
      output="upgrade.out" inputstring="no&#x0A;yes&#x0A;">                     
    <arg line="/c upgrade process F:/script"/>
</exec>
于 2013-06-20T20:06:42.537 回答