Kevin Jackson wrote:
Hi all,

I have a weird error caused by a property being wrong 50% of the time
and correct 50% of the time.

here's the relevant code:

build.properties
james.version=server-binary-next-major
james.home=/var/james
james.home.direct=/var/james-${james.version}

<macrodef name="ssh-cmd">
            <attribute name="command"/>
            <attribute name="fail" default="true"/>
            <sequential>
<sshexec host="${deploy.machine.address}" port="${deploy.machine.ssh.port}" username="root" password="${deploy.machine.root.user.password}"
                        command="@{command}"
                        failonerror="@{fail}" trust="true"/>
            </sequential>
        </macrodef>

<echo>james-${james.version}.tar.gz</echo>
<ssh-cmd command="cd /var;tar xzvpf
/root/james-${james.version}.tar.gz;chown -R james:james
${james.home.direct}"/>

Ok
the <echo> produces the following:

james-server-binary-next-major.tar.gz

in the ssh-cmd, the output of the tar xzvpf /root/james-${james.version}.tar.gz

tar xzvf /root/james-server-next-major.tar.gz

finally the chown -r james:james ${james.home.direct}
fails with /var/james/james-server-binary-next-major doesn't exist

so the echo thinks that ${james.version} = server-binary-next-major
the ssh-cmd macro thinks :
1 - ${james.version} = server-next-major
2 - then ${james.version} = server-binary-next-major

With ant properties are immutable, so what the hell is happening?

you are getting burned by the fact that the $ in the macro param is being double expanded. Once in passing to macrodef, and then when being passed to sshexec

the first tune the command runs, the ${james.version} is not set, but the second time it is.




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to