Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在ant中提示用户输入并根据输入采取操作_Ant - Fatal编程技术网

在ant中提示用户输入并根据输入采取操作

在ant中提示用户输入并根据输入采取操作,ant,Ant,我希望能够在ant执行期间提示用户输入。 我尝试执行的伪代码是: echo "Enter y or n:" read yorn if [ $yorn = 'y' ] then echo "$yorn" > /tmp/junk fi 以下是我所拥有的,但它不起作用: 41 <target name="-after-build"> 42 <input message="What's your name?" addpr

我希望能够在ant执行期间提示用户输入。 我尝试执行的伪代码是:

echo "Enter y or n:"
read yorn
if [ $yorn = 'y' ]
then
   echo "$yorn" > /tmp/junk
fi
以下是我所拥有的,但它不起作用:

 41         <target name="-after-build">
 42                 <input message="What's your name?" addproperty="your-name" validargs="Bob,Fred" />
 43                 <echo>What's up, ${your-name}?</echo>
 44                 <exec executable="/bin/echo">
 45                         <arg value="${your-name}"/>
 46                         <redirector output="/tmp/junk" alwayslog="true"/>
 47                 </exec>
 48                 <target name="ask_if_install">
 49                         <input message="do you want to run rsync?" addproperty="install_it" validargs="y,n" />
 50                 </target>
 51                 <target name="install.it"
 52                         if="install_it"
 53                         depends="ask_if_install">
 54                         <exec executable="/bin/echo">
 55                                 <arg value="${install_it}"/>
 56                                 <redirector output="/tmp/junk2" alwayslog="true"/>
 57                         </exec>
 58                 </target>
 59         </target>
41
42
43怎么了,${你的名字}?
44
45
46
47
48
49
50
51
54
55
56
57
58
59
以下是我得到的输出:

build.xml:48: Problem: failed to create task or type target
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
build.xml:48:问题:无法创建任务或类型目标
原因:名称未定义。
措施:检查拼写。
操作:检查是否已声明任何自定义任务/类型。
措施:检查是否发生了任何/声明。
您可以使用


也许这很抱歉,我的问题有点误导。我计划用一个更复杂的命令替换
/bin/echo
,比如
rsync——一堆arg
。红蟋蟀看见马编辑了吗。与元素类型“exec”关联的属性“if:true”的前缀“if”未绑定。当我尝试执行
@Red Cricket时,是否有Oops!我忘了那一点。我能做这个吗
还是最好将xmlns选项放在项目标记中?
<project  xmlns:if="ant:if"  xmlns:unless="ant:unless">

    <input  message="Enter y or n:" validargs="y,n" addproperty="yes.or.no" />

    <condition property="yes.is.true">
      <equals arg1="${yes.or.no}" arg2="y" />
    </condition>


    <concat destfile="junk" if:true="${yes.is.true}">${yes.or.no}</concat>

</project>
<exec executable="echo" if:true="${yes.is.true}">
    <arg value="${yes.or.no}" />
</exec>