ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maureen Troendle <troen...@ca.ibm.com>
Subject Selectively delete files/folders on another server
Date Wed, 15 Dec 2010 17:30:02 GMT
I'm using Ant to deploy various components to different servers and I'm 
looking for a way to enumerate files/folders on a remote server and then 
selectively delete them.  So I don't know everything that will be there 
but I know the folders I want to leave undeleted.  I'm looking for some 
kind of foreach loop or something that will work for me.
I'm using Ant 1.7.0 on AIX 5.3 servers.
I'm looking for help on how to enumerate each line in a file.  And then I 
guess the best method would be to modify that file to remove the folders I 
don't want to delete and use that to sshexec once and delete files/folders 
rather than doing an sshexec for each line item.  ie. sshexec across once 
and delete all in a loop versus loop and sshexec for each item.

I can echo what's in that remote location using this:
    <sshexec host="${target.server}" username="${target.user}" 
password="${targe
t.password}" failonerror="true" trust="true" 
output="${deploy.temp.dir}/remote
list.txt" append="false" command=". $HOME/.profile; cd ${dc.fs}; ls" />

Now I'm trying to read remotelist.txt line by line and delete everything 
excluding certain folders.  I'm having trouble splitting the lines.
Here's a couple of things I've tried.
1.
    <foreach list="${deploy.temp.dir}/remotelist.txt" delimiter=" " 
param="itemfound" target="rmitem" />

In target, rmitem, for now I'm just trying to echo the lines in 
remotelist.txt but eventually I'll need to do an sshexec with an rm -rf 
${line}.

2. 
    <foreach item="Line" in="${deploy.temp.dir}/remotelist.txt" 
property="item
found">
       <echo message="Read line ${itemfound}" />
    </foreach>

Error: foreach doesn't support the "item" attribute

3. 
    <loadfile property="allfiles" 
file="${deploy.temp.dir}/remotelist.txt"/>
    <for list="${allfiles}" param="itemfound">
       <echo message="Read line ${itemfound}" />
    </for>
Error: loadfile doesn't support the "file" attribute

4. 
    <loadfile srcFile="${deploy.temp.dir}/remotelist.txt" property="line">
       <echo message="Read line ${line}" />
    </loadfile>
Error: loadfile doesn't support the nested "echo" element.

5. 
    <loadfile srcFile="${deploy.temp.dir}/remotelist.txt" 
property="line"/>
    <echo message="Read line ${line}" />
Error: this echos all of items found in ls as 1 item, ${line} 

6. 
    <loadfile property="src" srcFile="${deploy.temp.dir}/remotelist.txt"/>
      <for param="line" list="${src}" delimiter="${line.separator}">
        <sequential>
           <echo message="Read line ${line}" />
        </sequential>
      </for>
Error: echos 1 line multiple times - [echo] Read line: ${line}



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message