permaculture playing cards*
The moose likes Ant, Maven and Other Build Tools and the fly likes append a  batch file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "append a  batch file" Watch "append a  batch file" New topic
Author

append a batch file

Muhammad Ahsan
Greenhorn

Joined: Feb 21, 2005
Posts: 5
I am using websphere Ant 1.5.2 for my script

I want to edit this batch file

setlocal

set CLASSPATH=e:\progra~1\checks~1\csmm\java\rdrdispatch.jar;e:\progra~1\checks~1\csmm\java\rdrserver.jar;e:\progra~1\checks~1\csmm\java\csmutils.jar;%CLASSPATH%
java -DCSMETRICS_PROPERTIES=e:\\progra~1\\checks~1\\csmm\\java\\rdragent.properties com.checksol.metrics.server.CollectorServer rdrdbsecurity.dat

I want to put

set PATH=C:\Progra~1\WebSph~1\AppSer~1\java\jre\bin\;%PATH%

between setlocal and SET CLASSPATH

I try to use <concat> and echo tags but i don,t know exactly how to do that.

Saad
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
Are you saying you want to use ant to edit a batch file with these contents:


setlocal

set CLASSPATH=e:\progra~1\checks~1\csmm\java\rdrdispatch.jar;e:\progra~1\checks~1\csmm\java\rdrserver.jar;e:\progra~1\checks~1\csmm\java\csmutils.jar;%CLASSPATH%
java -DCSMETRICS_PROPERTIES=e:\\progra~1\\checks~1\\csmm\\java\\rdragent.properties com.checksol.metrics.server.CollectorServer rdrdbsecurity.dat



and the edit you want to do it to insert a line between the two existing lines?

Why do you want to do this? You only need the PATH in some versions of the batch file?
Muhammad Ahsan
Greenhorn

Joined: Feb 21, 2005
Posts: 5
I am working on the Automation of a big system , the system consist of
lot of jacl scripts, batch files and Ant files. Instead of using perl for
text processing, I choose Ant , since we are already using ant for automating a build.

Saad
Muhammad Ahsan
Greenhorn

Joined: Feb 21, 2005
Posts: 5
You only need the PATH in some versions of the batch file?

What do you mean by that , please explain with an example ! I will really apprecaite that

thanks
Saad
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
Sorry to confuse you. I was just trying to figure out why you needed to use ant to put a path line in the batch file. The example is so simple I'm thinking if you need it there just put it there. Now if you need different values there for different environments I can see how ant can help with filters/tokens. Or maybe you need that path in LOTS of places and you only want to have to change it in one place when necessary.

Ant uses a token separator as @, put values in text files that you want replaced using the separator and a token such as "SOME_PATH":

file needs path:
@SOME_PATH@

properties file or build file defines replacement values
SOME_PATH=...put info here...


see ant manual,
e.g., Replace Task or Copy Task.

This example is from a build file that I inherited, just to show you're not limited to replacing a simple property value:

From copy task info in ant manual:

Copy a set of files to a directory, replacing @TITLE@ with Foo Bar in all files.


I hope that points you in the right direction.
[ February 25, 2005: Message edited by: Carol Enderlin ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: append a batch file