Hi Steve,

I tried to use "Variables" Task in ant-contrib, but it replicate the 
same result as Dick did.
My build.xml is:

<?xml version="1.0" ?>
<project name="build" basedir="." default="test">
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
  <target name="test">
     <script language="javascript">
        <![CDATA[
          project = self.getProject();
          echo = project.createTask("echo");
          variable = project.createTask("var");
          variable.setName("theVal");
          variable.setValue("foo");
          variable.execute();
          echo.setMessage(project.getProperty("theVal"));
          echo.perform();
          echoval.execute();
          variable.setName("theVal");
          variable.setValue("bar");
          variable.execute();
          echo.setMessage(project.getProperty("theVal"));
          echo.perform();
          echoval.execute();
        ]]>
      </script>
   </target>
   <target name="echoval">
      <echo>${theVal}</echo>
   </target>
</project>

The Result is:

c:\>ant -v
Apache Ant version 1.6.2 compiled on July 16 2004
Buildfile: build.xml
Detected Java version: 1.4 in: C:\j2sdk1.4.1_07\jre
Detected OS: Windows XP
parsing buildfile C:\build.xml with URI = file:///C:/build.xml
Project base dir set to: C:\
parsing buildfile 
jar:file:/C:/apache-ant-1.6.2/lib/ant-contrib.jar!/net/sf/antcontrib/antlib.xml 
with URI = 
jar:file:/C:/apache-ant-1.6.2/lib/ant-contrib.jar!/net/sf/antcontrib/antlib.xml
Build sequence for target `test' is [test]
Complete build sequence is [test, echoval, ]

test:
     [echo] foo
     [echo] foo
     [echo] bar
     [echo] foo

BUILD SUCCESSFUL
Total time: 0 seconds
c:\>

Why ?
What's wrong with my description about "Variable" task ?
Any comments will be very appreciated.

Best Regards,
trad-ex

>Dick, Brian E. wrote:
>> I have just a day to get this working. These are production machines, so
>> I can't deploy anything to them.
>> 
>> I'm using sshexec to remotely ping from a unix host and using rcmd to
>> remotely ping from a windows host. I redirect the output from these
>> tasks to a file and then use loadfile with a filterchain to load the
>> ipaddress into a property.
>> 
>> This works all fine and dandy except I need to do it in a loop, so that
>> led me to the script task. But I was having problems getting the
>> ipaddress set by loadfile back to the script. I didn't want to create
>> 20x100 properties, but if that's what it takes, so be it.
>> 
>
>In that case, grab the <var> task from ant-contrib, which can be used to 
>erase a property before you reuse it.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]

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

Reply via email to