Modify a text or xml file

Hi all,

I want to write a shell which would allow me to edit a text file or a xml file.

Basically i want to add a new node in a existing xml file. The values for this new node are based on user input.

Thanks in advance
Zing

zing, can you explain more about what you're trying to do?

Why not have the "user" just use vi to edit the file and add a node..? And can you list a sample "node" as it relates to xml, so we know exactly what you're talking about?

I am trying to install a new portal (in TOMCAT) using sh.

The portal to take effect needs to have an entry in the server.xml provide with Tomcat installation.

The following text needs to be added where the values for path and docBase are given by the user.

<Context path="/newPortal" docBase="/export/home/newPortal" debug="0"></Context>

There are several other steps before and after this and i want to automate the process. I know that it is last option that the user manually enters the content.

and what do you do if 2 users enter the same information?

XSLT is designed to transform XML to XML.

There are nodes for text, attributes, comments, namespaces and processing instructions.

XSLT acts as a process. It reads in the XML and the style sheet containing the template for nodes.

The user input you wish to enter as nodes in the new XML tree, have to meet the
well-formed requirements of XML.

For more info go to
http://www.cafeconleche.org

The other alternative is to hack it out in perl, because sh may
not be that powerful.

on the perlish side note. there are xslt modules for perl.

but my main question still stands. what do you do if 2 users enter the same parameters.

Is that a question or a comment?

The cheap and cheerful method is simply to use
the ed or ex editor. It can be embedded in shell
scripts.

Hi Optimus_P,

As for your query, i already have the necessary checks to ensure that 2 users donot enter the same value. Also at one point in time there will only single instance of the shell running.

Thanks everyone for your inputs but what i am trying is to build a script purely using base shell features