ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antoine Levy-Lambert <anto...@gmx.de>
Subject Re: Selectively delete files/folders on another server
Date Wed, 15 Dec 2010 19:12:20 GMT
Hello Maureen,

would it be possible to install ant on the target machines and move the 
logic to determine folders
to be deleted there ? this might be a way to do this work more simply.

What is the criteria according to which you know which directories/files 
to delete or to preserve ?

Regards,

Antoine

On 12/15/2010 12:30 PM, Maureen Troendle wrote:
> 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}
>
>
>


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


Mime
View raw message