Hi,
During an installation process in a bash script I need to do 2 things with 2 XML files. Does the use of sed affect in any way the XML file ?
1.Add to a section in <ServerListeners> section
<ServerListener>
<BaseClass>myapp.module.WowConfigurator</BaseClass>
</ServerListener>
The below code does the job, but it doesn;t format the xml file by adding tabs and all. Is that ok from an XML file point of view?
ISLISTENER=`grep -n "myapp" $WOW_HOME/conf/Server.xml|cut -d":" -f1 |head -1`
if [ ${ISLISTENER} == "" ]
then
INSERTLINE=`grep -n "ServerListeners" $WOW_HOME/conf/Server.xml|cut -d":" -f1 |head -1`
sed -e ''${INSERTLINE}'a\</ServerListener>''' $WOW_HOME/conf/Server.xml > $WOW_HOME/conf/Server.xml_new
mv $WOW_HOME/conf/Server.xml_new $WOW_HOME/conf/Server.xml
sed -e ''${INSERTLINE}'a\<BaseClass>myapp.module.WowConfigurator</BaseClass>''' $WOW_HOME/conf/Server.xml > $WOW_HOME/conf/Server.xml_new
mv $WOW_HOME/conf/Server.xml_new $WOW_HOME/conf/Server.xml
sed -e ''${INSERTLINE}'a\<ServerListener>''' $WOW_HOME/conf/Server.xml > $WOW_HOME/conf/Server.xml_new
mv $WOW_HOME/conf/Server.xml_new $WOW_HOME/conf/Server.xml
fi
- With a sed command I need to replace the value of a first occurrence of a parameter:
The xml file contains:
<IpAddress>*</IpAddress>
<Port>1935</Port>
And I need to replace with $BINDADDRESS and $BINDPORT variables. This I didn't manage to figure it out.
Thanks,
Bianca