Ant exec 任务:如何从控制台标准输入读取输入? [英] Ant exec task: How can I read input from console stdin?

查看:27
本文介绍了Ant exec 任务:如何从控制台标准输入读取输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我调用 Ant exec 任务,该任务需要接受来自控制台标准输入的输入.不幸的是,我找不到办法做到这一点.stdin 文件句柄在运行时似乎对控制台输入关闭.

I have a call to Ant exec task that needs to accept input from console stdin. Unfortunately, I cannot find a way to do this. The stdin filehandle seems closed to console input at runtime.

可以使用属性inputinputstring 指定输入.但是,我需要在控制台提示用户输入.

It is possible to specify input using attributes input and inputstring. However, I need to prompt for user input at the console.

我该怎么做?

推荐答案

来自文档 任务:

请注意,您无法与分叉的程序,唯一的发送方式输入它是通过输入和输入字符串属性.还要注意的是自 Ant 1.6 起,任何尝试读取分叉程序中的输入将收到 EOF (-1).这是一个改变从 Ant 1.5 开始,这样的尝试会阻塞.

Note that you cannot interact with the forked program, the only way to send input to it is via the input and inputstring attributes. Also note that since Ant 1.6, any attempt to read input in the forked program will receive an EOF (-1). This is a change from Ant 1.5, where such an attempt would block.

您可以尝试使用 input-task 来提示输入ant-buildfile 并使用 exec 的 inputstring-attribute 传递这些输入.目前我想不出更好的选择.

You could try to use the input-task to prompt for input in the ant-buildfile and pass these input with the inputstring-attribute of exec. I can't think of a better option at the moment.

这篇关于Ant exec 任务:如何从控制台标准输入读取输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆