newlines in property from -D argument

View: New views
4 Messages — Rating Filter:   Alert me  

newlines in property from -D argument

by andrewdanger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

i am running ant from a bash script. i have a variable that contains command output, including newlines. when i try to pass the variable to ant like

ant -Dbuild.log="${BUILD_LOG}"

newlines aren't preserved in the build.log property. do i need to massage the output before i give it to ant as a property?

Re: newlines in property from -D argument

by Francis Galiegue-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Jun 24, 2009 at 16:53,
andrewdanger<andrewdangermuro+nabble@...> wrote:
>
> i am running ant from a bash script. i have a variable that contains command
> output, including newlines. when i try to pass the variable to ant like
>
> ant -Dbuild.log="${BUILD_LOG}"
>
> newlines aren't preserved in the build.log property. do i need to massage
> the output before i give it to ant as a property?
> --

Why don't you just put commands in a script and pass the path to that
script as an argument?

--

Francis Galiegue
ONE2TEAM
Ingénieur système
Mob : +33 (0) 683 877 875
Tel : +33 (0) 178 945 552
fge@...
40 avenue Raymond Poincaré
75116 Paris

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: newlines in property from -D argument

by andrewdanger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

yeah, this is an option, but i need it all in a script because i need to do non-ant things and i find it easier to do non-ant things in bash rather than with the <exec> task. anyway, i did find the solution, which is to escape newlines in the command output:

VAR=`cmd | sed 's/$/\\/g'` (though this actually replaces the last character of the line, it doesn't match \n, but it works)

thanks for the quick reply though.

Francis Galiegue-4 wrote:
Why don't you just put commands in a script and pass the path to that
script as an argument?

--

Francis Galiegue
ONE2TEAM
Ingénieur système
Mob : +33 (0) 683 877 875
Tel : +33 (0) 178 945 552
fge@one2team.com
40 avenue Raymond Poincaré
75116 Paris

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org

Re: newlines in property from -D argument

by Francis Galiegue-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Jun 26, 2009 at 15:21,
andrewdanger<andrewdangermuro+nabble@...> wrote:
>
> yeah, this is an option, but i need it all in a script because i need to do
> non-ant things and i find it easier to do non-ant things in bash rather than
> with the <exec> task. anyway, i did find the solution, which is to escape
> newlines in the command output:
>

Err...

<exec executable="/bin/bash" failonerror="true">
    <arg value="${the.script}"/>
    <arg value="arg1tothescript"/>
    <!-- and so on -->
</exec>


--

Francis Galiegue
ONE2TEAM
Ingénieur système
Mob : +33 (0) 683 877 875
Tel : +33 (0) 178 945 552
fge@...
40 avenue Raymond Poincaré
75116 Paris

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...