Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ant task failed due to confirmation prompt

 
T. Anthony Chen
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an Exec task that runs a command which, depending on the situation at runtime, may prompt for user confirmation. Running the command alone, the user can choose to type Y or N, the default is N. Running from Ant, the task always fails if the prompt happens. I am guessing that is because a carriage return, which means N to the prompt, is always fed to it. But what I really want to give it is an Y.

Is there a way to feed a key stroke to the command when it is executed by Ant? Thanks.
 
Dmitry Melnik
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Windows most shell commands have an option to be executed in a "quiet" mode, without confirmation prompts. You can find out the specific syntax for such commands by entereing "help {your command}" in a console window.

There is also a way to redirect console input for a command to a text file with answers. Here is an example "xcopy foo.txt bar <yes.txt" Where the file yes.txt contains yes-answer(s)

I guess, similar techniques could be used with Unix shells, with a slightly different syntax.
 
T. Anthony Chen
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dmitry, I went for your second approach and it worked! Many thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic