You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Oki DZ <ok...@pindad.com> on 2003/04/01 04:59:27 UTC

Getting input

Hi,

I have something like the following in my build.xml:
  <target name="execute" depends="compile" description="execute the 
app">
    <exec dir="${ojbhome}" executable="${javahome}/bin/java">
      <arg line="MyClass"/>
    </exec>
  </target>

MyClass uses Readline.readline(<prompt>) (from 
java-readline.sourceforge.net). Unfortunately, the input is suppressed 
by Ant (meaning, the prompt is not displayed). How can I get it working?

BTW, if I use BufferedReader and have the InputStream from System.in, it 
would be the same thing.

Thanks in advance,
Oki



Re: Getting input

Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
On Tue, 1 Apr 2003 03:03 pm, Conor MacNeill wrote:
>
> If input is not
> provided in this form and a task requests input it will be sent eventually
> to the System.in stream. 

Just to update - this is true for in-VM Java tasks only. External tasks such 
as <exec> and forked <java> can only get input from a file or property.

-- 
Conor MacNeill
Blog: http://codefeed.com/blog/


Re: Getting input

Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
On Tue, 1 Apr 2003 12:59 pm, Oki DZ wrote:
> Hi,
>
> I have something like the following in my build.xml:
>   <target name="execute" depends="compile" description="execute the
> app">
>     <exec dir="${ojbhome}" executable="${javahome}/bin/java">
>       <arg line="MyClass"/>
>     </exec>
>   </target>
>
> MyClass uses Readline.readline(<prompt>) (from
> java-readline.sourceforge.net). Unfortunately, the input is suppressed
> by Ant (meaning, the prompt is not displayed). How can I get it working?
>
> BTW, if I use BufferedReader and have the InputStream from System.in, it
> would be the same thing.
>
> Thanks in advance,
> Oki

In Ant 1.5, you cannot do this. The input stream of processes such as <java> 
and <exec> is not connected to anything. You can redirect input by using the 
external shell to redirect the input for you. This is pretty messy (i.e. 
platform dependent).

In Ant 1.6, you can use a file or a property as input. If input is not 
provided in this form and a task requests input it will be sent eventually to 
the System.in stream. Currently, however, this is managed independently of 
the output stream, which is buffered, so your prompt may still not appear. 
I'm looking into that ...

-- 
Conor MacNeill
Blog: http://codefeed.com/blog/