You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Raymond Berg (ALLETE)" <rb...@mnpower.com> on 2008/07/01 20:44:50 UTC

Multiple

I've got a situation where I need to search deployment files for various
server names of a variable count when moving from staging to production
automatically. However, I can't seem to figure out how to handle a
dynamic replace count. I was looking at the script task but found no
syntax that seemed to help. (Also investigated path tools and the few
string operations available)

I'm debating whether to create a new Ant task, but I'm not comfortable
enough with my skills yet to attempt this.

If it helps, my script is currently passing in a single delimited string
as follows: find1~replace#find2~replace2#...#findn~replacen

Any ideas?

Raymond

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


Re: Multiple

Posted by Gilbert Rebhan <an...@schillbaer.de>.
Raymond Berg (ALLETE) schrieb:
> I've got a situation where I need to search deployment files for various
> server names of a variable count when moving from staging to production
> automatically. However, I can't seem to figure out how to handle a
> dynamic replace count.

sorry - it's not clear to me =
searching for something, OK
dynamic replace count ??

already the subject of your mail = "Multiple"
is not that significant

>I was looking at the script task but found no
> syntax that seemed to help. (Also investigated path tools and the few
> string operations available)

when using <script> combined with a full blown language that runs
in BSF/VM you have all the power of a real language at your fingertips,
nearly everything is possible.You have also access to the ant api.
(j)ruby, groovy recommended or if you want a more 'java look alike'
syntax use beanshell,javascript(rhino)

> I'm debating whether to create a new Ant task, but I'm not comfortable
> enough with my skills yet to attempt this.

we need more details ...

Regards, Gilbert

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


RE: Multiple

Posted by "Raymond Berg (ALLETE)" <rb...@mnpower.com>.
I very much appreciate the responses on this. I think this is probably
the best solution for the issue. Somehow I missed the ability to use a
replacefilterfile in the documentation. 

As for the dynamic replace count, that's just my condensed and
confusticated way of saying that there may be any number of replaceable
strings for each project (some have one dependent server, some have
dozens). A filter file appears to hanle this and I think this is going
to be the best solution, although possibly not the cleanest as files
will have to be created for dozens of concurrent deployments and erased
on completion. 

I should like to hope that ANT has/will add a core function or extension
like what Jim Cant wrote in response to this issue (for Perl):

"perl -i.bak -ape "s/pat1/repl1/g;s/pat2/repl2/g;...;s/patN/replN/g"

While Perl is known for its ability to manage file/user input like a
crazy person, I think the ability to use a string for multiple search
and replaces would be desirable. I looked at the equivalent RegEx
parsing in the ANT library and they use the Java approach, which is
logical but not necessarily desirable for build scripts.

Something to think about, but thanks again! I'm off to finish the job!

-Raymond

-----Original Message-----
From: Anderson, Rob (Global Trade) [mailto:Rob.Anderson@nike.com] 
Sent: Tuesday, July 01, 2008 2:02 PM
To: Ant Users List
Subject: RE: Multiple 

Why not use the existing replace task with the replacefilterfile
attribute? I'm not sure what you mean by 'dynamic replace count'.

-Rob Anderson

-----Original Message-----
From: Raymond Berg (ALLETE) [mailto:rberg@mnpower.com] 
Sent: Tuesday, July 01, 2008 11:45 AM
To: Ant Users List
Subject: Multiple 

I've got a situation where I need to search deployment files for various
server names of a variable count when moving from staging to production
automatically. However, I can't seem to figure out how to handle a
dynamic replace count. I was looking at the script task but found no
syntax that seemed to help. (Also investigated path tools and the few
string operations available)

I'm debating whether to create a new Ant task, but I'm not comfortable
enough with my skills yet to attempt this.

If it helps, my script is currently passing in a single delimited string
as follows: find1~replace#find2~replace2#...#findn~replacen

Any ideas?

Raymond

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


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


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


RE: Multiple

Posted by "Anderson, Rob (Global Trade)" <Ro...@nike.com>.
Why not use the existing replace task with the replacefilterfile
attribute? I'm not sure what you mean by 'dynamic replace count'.

-Rob Anderson

-----Original Message-----
From: Raymond Berg (ALLETE) [mailto:rberg@mnpower.com] 
Sent: Tuesday, July 01, 2008 11:45 AM
To: Ant Users List
Subject: Multiple 

I've got a situation where I need to search deployment files for various
server names of a variable count when moving from staging to production
automatically. However, I can't seem to figure out how to handle a
dynamic replace count. I was looking at the script task but found no
syntax that seemed to help. (Also investigated path tools and the few
string operations available)

I'm debating whether to create a new Ant task, but I'm not comfortable
enough with my skills yet to attempt this.

If it helps, my script is currently passing in a single delimited string
as follows: find1~replace#find2~replace2#...#findn~replacen

Any ideas?

Raymond

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


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


Re: Multiple

Posted by David Weintraub <qa...@gmail.com>.
Take a look at filtering when you do a <copy>. In your files, you put
target strings like "@serverName@" and "@user@. Here's an example from
one of my build.xml:

        <copy todir="${dest.dir}"/>
            <fileset dir="${template.dir}"/>
             <filterset begintoken="@" endtoken="@">
                <filtersfile file="${deploy.properties.file}"/>
            </filterset>
        </copy>

The <filterset> sub-task does the replacement. It finds all the tokens
that are in the form of "@server@" or "@user@" and replaces them with
the values found in the "${deploy.properties.file}".


--
David Weintraub
qazwart@gmail.com


On Tue, Jul 1, 2008 at 2:44 PM, Raymond Berg (ALLETE) <rb...@mnpower.com> wrote:
> I've got a situation where I need to search deployment files for various
> server names of a variable count when moving from staging to production
> automatically. However, I can't seem to figure out how to handle a
> dynamic replace count. I was looking at the script task but found no
> syntax that seemed to help. (Also investigated path tools and the few
> string operations available)
>
> I'm debating whether to create a new Ant task, but I'm not comfortable
> enough with my skills yet to attempt this.
>
> If it helps, my script is currently passing in a single delimited string
> as follows: find1~replace#find2~replace2#...#findn~replacen
>
> Any ideas?
>
> Raymond
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

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


RE: Multiple

Posted by "Raymond Berg (ALLETE)" <rb...@mnpower.com>.
Sorry for the delayed response! Thanks for the suggestion, but I'm not
totally comfortable creating another language dependency for the task.
That's not to say that this isn't the faster, if not altogether better,
solution for this issue. 

You are right, though, the solution is to evaluate files and perform
multiple replacements on each provided string. My apologies for the
confusion.

-Raymond


-----Original Message-----
From: Jim Cant [mailto:cant_jim@hotmail.com] 
Sent: Wednesday, July 02, 2008 8:40 PM
To: user@ant.apache.org
Subject: Re: Multiple


If I understand your problem correctly, what you are trying to do is do
a
global search and replace in a file.  I don't think ant is the
appropriate
tool for this; I'd suggest Perl.  Here's a command that replaces every
occurence of each pattern in a line for all lines in a file and saves
the
original file 'fileIn.txt' to 'fileIn.txt.bak

perl -i.bak -ape "s/pat1/repl1/g;s/pat2/repl2/g;...;s/patN/replN/g"

You should be able to run this with the <exec> task.

Note that if a replacement results in a line that matches a pattern that
you
match later, that replacement will be made which may not be what you
want.



Raymond Berg (ALLETE) wrote:
> 
> I've got a situation where I need to search deployment files for
various
> server names of a variable count when moving from staging to
production
> automatically. However, I can't seem to figure out how to handle a
> dynamic replace count. I was looking at the script task but found no
> syntax that seemed to help. (Also investigated path tools and the few
> string operations available)
> 
> I'm debating whether to create a new Ant task, but I'm not comfortable
> enough with my skills yet to attempt this.
> 
> If it helps, my script is currently passing in a single delimited
string
> as follows: find1~replace#find2~replace2#...#findn~replacen
> 
> Any ideas?
> 
> Raymond
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 

-- 
View this message in context:
http://www.nabble.com/How-do-you-sort-and-remove-duplicates-lines-from-a
-file---tp18219748p18250207.html
Sent from the Ant - Users mailing list archive at Nabble.com.


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


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


Re: Multiple

Posted by Jim Cant <ca...@hotmail.com>.
If I understand your problem correctly, what you are trying to do is do a
global search and replace in a file.  I don't think ant is the appropriate
tool for this; I'd suggest Perl.  Here's a command that replaces every
occurence of each pattern in a line for all lines in a file and saves the
original file 'fileIn.txt' to 'fileIn.txt.bak

perl -i.bak -ape "s/pat1/repl1/g;s/pat2/repl2/g;...;s/patN/replN/g"

You should be able to run this with the <exec> task.

Note that if a replacement results in a line that matches a pattern that you
match later, that replacement will be made which may not be what you want.



Raymond Berg (ALLETE) wrote:
> 
> I've got a situation where I need to search deployment files for various
> server names of a variable count when moving from staging to production
> automatically. However, I can't seem to figure out how to handle a
> dynamic replace count. I was looking at the script task but found no
> syntax that seemed to help. (Also investigated path tools and the few
> string operations available)
> 
> I'm debating whether to create a new Ant task, but I'm not comfortable
> enough with my skills yet to attempt this.
> 
> If it helps, my script is currently passing in a single delimited string
> as follows: find1~replace#find2~replace2#...#findn~replacen
> 
> Any ideas?
> 
> Raymond
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-do-you-sort-and-remove-duplicates-lines-from-a-file---tp18219748p18250207.html
Sent from the Ant - Users mailing list archive at Nabble.com.


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