Computing.Net > Forums > Unix > How to add a java tag to the data

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

How to add a java tag to the data

Reply to Message Icon

Name: haris
Date: April 13, 2009 at 14:21:22 Pacific
OS: Unix
Subcategory: General
Comment:

Dear all,

I have a shell script with perl commands which I developed by looking at various forums. Now I struck up with a command to add a <java> tag. Please help me.

Here is my scenario:

<services>
- <bw name="test.par">
<enabled>true</enabled>
- <bindings>
- <binding name="test_1_0_0">
<machine>Lenovo</machine>
- <product>
<type>bwengine</type>
<version />
<location />
</product>
<description />
<contact />
- <shutdown>
<checkpoint>false</checkpoint>
<timeout>0</timeout>
</shutdown>
</binding>
</bindings>

To the above xml I would like to add the following tag after </product> using a shell command.

<java>
<initHeapSize>32</initHeapSize>
<maxHeapSize>256</maxHeapSize>
<threadStackSize>256</threadStackSize>
</java>

which will look in the following way.

<services>
- <bw name="test.par">
<enabled>true</enabled>
- <bindings>
- <binding name="test_1_0_0">
<machine>Lenovo</machine>
- <product>
<type>bwengine</type>
<version />
<location />
</product>
- <java>
<initHeapSize>32</initHeapSize>
<maxHeapSize>256</maxHeapSize>
<threadStackSize>256</threadStackSize>
</java>
<description />
<contact />
- <shutdown>
<checkpoint>false</checkpoint>
<timeout>0</timeout>
</shutdown>
</binding>
</bindings>

Can anyone help me by providing a suitable command to add the above tag. If you need any more details please let me know.

Thanks,
HK



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: April 13, 2009 at 15:49:55 Pacific
Reply:

I assume that the java tag you want to insert is in a file called javatag.txt. Use sed to read javatag.txt after the string ending in <product>:

#!/bin/ksh

sed '/<product>$/r javatag.txt' datafile
# end

Fishmonger can probably give you a perl solution.


0

Response Number 2
Name: haris
Date: April 13, 2009 at 16:45:14 Pacific
Reply:

Hi Nails,

Thank you for the information. I tried with the command you provided. In the terminal it is giving all the xml which is present but not able to add anything to the xml. Can you please give little more info about this?

Actually when I run a middleware command it will generate xml (which is the first xml without java tag) from the archive package. So I can't run the given sed command after the product because I dont know exactly where it will present in the file?

As I explained, after generating xml, I would like to add java tag to the xml. Please let me know if it will work for this scenario. Let me know if you need further info.

Hey Fishmonger,

Is there any perl command to solve my problem? If so, can you please provide the command.

Thanks much for the help,

HK


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: How to add a java tag to the data

Running a Java class in the crontab www.computing.net/answers/unix/running-a-java-class-in-the-crontab/4076.html

how to add a static route www.computing.net/answers/unix/how-to-add-a-static-route/2017.html

How to get latest updated file in a folder www.computing.net/answers/unix/how-to-get-latest-updated-file-in-a-folder/8497.html