Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing input to Ant's <exec> task

Tags:

ant

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?

like image 307
mikek Avatar asked May 06 '10 15:05

mikek


People also ask

How do you pass an argument to an Ant build?

Discussion. If you want to pass arguments to Ant, you can enter those arguments in the Arguments box of the dialog opened by right-clicking your build file, clicking Run Ant, and clicking the Main tab. You can see that dialog in Figure 7-15 (note that you also can set the build file location and base directory here).

How do I call Ant target from command line?

To run the ant build file, open up command prompt and navigate to the folder, where the build. xml resides, and then type ant info. You could also type ant instead. Both will work,because info is the default target in the build file.

What is Antcall in build XML?

Description. Call another target within the same buildfile optionally specifying some properties (params in this context). This task must not be used outside of a target . By default, all of the properties of the current project will be available in the new project.

What is Ant task in Java?

Ant tasks are the units of your Ant build script that actually execute the build operations for your project. Ant tasks are usually embedded inside Ant targets. Thus, when you tell Ant to run a specific target it runs all Ant tasks nested inside that target.


1 Answers

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

like image 171
MatsT Avatar answered Oct 19 '22 14:10

MatsT