输入传递到Ant的&LT;&EXEC GT;任务 [英] Passing input to Ant's <exec> task
问题描述
我必须采取在inputed密码后,运行标准-task Ant脚本:
&LT;输入消息=密码:方法addProperty =密码&GT;
&LT;处理器类名=org.apache.tools.ant.input.SecureInputHandler/&GT;
&LT; /输入&GT;&LT; EXEC可执行=/ bin / sh的输入=$ {}密码failonerror =真&GT;
&LT; ARG行=' - CmyScript.sh/&GT;
&LT; / EXEC&GT;
脚本myScript.sh会提示用户输入密码,而且,这是我的理解是从输入的应该是继电器输入无论&LT在Ant文件; EXEC&GT;
任务执行,而是我得到(用于输入密码foobar的)
[执行]无法打开的/ usr /本地/ foobar的
随后是从我的脚本抱怨的密码不正确的堆栈跟踪...所以显然我已经理解的文档错误。是否有人知道如何处理来自外部脚本提示输入蚂蚁?
输入=$ {}密码
这将尝试从文件$ {}密码读取和内容发送到脚本。尝试使用:
inputstring =$ {}密码
来代替。这将发送字符串本身而不是把它像一个文件名
I have an Ant script running a standard -task after taking in an inputed password:
<input message="Password:" addproperty="password">
<handler classname="org.apache.tools.ant.input.SecureInputHandler" />
</input>
<exec executable="/bin/sh" input="${password}" failonerror="true">
<arg line='-c "myScript.sh"' />
</exec>
The script myScript.sh prompts the user for a password, and, it was my understanding that from the Ant documentation that input is supposed relay input into whatever the <exec>
task is executing, but instead I get (for entering the password foobar)
[exec] Failed to open /usr/local/foobar
which is followed by a stack trace from my script complaining about an incorrect password...so obviously I've understood the documentation wrong. Does anybody know how to handle prompted input from external scripts in Ant?
input="${password}"
This will try to read from the file ${password} and send the contents into your script. Try using:
inputstring="${password}"
instead. This will send the string itself instead of treating it like a filename
这篇关于输入传递到Ant的&LT;&EXEC GT;任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!