ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maureen Troendle <>
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}" 
t.password}" failonerror="true" trust="true" 
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.
    <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 

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

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

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

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

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

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

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