ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maureen Troendle <troen...@ca.ibm.com>
Subject Re: Selectively delete files/folders on another server
Date Wed, 15 Dec 2010 20:15:00 GMT
The idea behind this is that there is one deployment server that deploys 
code to multiple envs with various middleware  components (Oracle, 
Websphere, Message Broker, Business Objects) stored on multiple lpars.  So 
I need to drop files, run scripts, deliver middleware components to 3 
lpars for any given environment.
We don't really want to install Ant on all systems, just the deployment 
server.  We are already doing a lot of this type of work  this way.  I 
just need to learn how to read a file by line in Ant and get the output of 
that line so I can perform an action on it.

criteria for deleting
I have a set location with set folders that get created and deleted.  The 
problem is other people could also drop information to that location that 
I want to cleanup.
ie. mainfolder
         folder1
         folder2
         folder3
         folder4
I want to delete folder3 and 4 at this location but leave folder1 and 2 (I 
know the names of the folders so the exclude decision is not an issue). 
I also want to delete anything else that someone drops there.
ie.   folder5
       text.txt

I am archiving the whole thing first so zip'ing mainfolder.  Then cleaning 
up part of it and recreating part of it, but some of it needs to stay. ie. 
leaving an archive directory where the zips are stored.  Leaving folder 
where part of app installed.


Regards,
Maureen

Maureen Troendle
IBM Canada
phone: 250-220-1147
cell:      250-661-2145
fax:       250 220-1122
email:  troendle@ca.ibm.com



From:   Antoine Levy-Lambert <antoine@gmx.de>
To:     Ant Users List <user@ant.apache.org>
Date:   12/15/2010 11:14 AM
Subject:        Re: Selectively delete files/folders on another server



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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message