I got the following instructions:
sudo nano /etc/tomcat7/tomcat-users.xmladd a user who can access the manager-guiand admin-gui:
<tomcat-users> <user username="admin" password="password" roles="manager-gui,admin-gui"/> </tomcat-users>in other words:
I need to modify xml file, rather: in xml document add new xml tag (<user>) in existing xml tag (<tomcat-users>).
I do not want to do it manually all times and I think about ability to automate this step in terminal.
What is the best way to do it?
Main problem fom me is how can I add new child xml tag in parent xml tag via terminal without manual manipulation?
I am using Ubuntu 14.10.
Solution:
sed -i 's/<tomcat-users>/<tomcat-users>\n<user username="user" password="password" roles="manager-gui,admin-gui"\/>/' /etc/tomcat7/tomcat-users.xml 3 1 Answer
Do:
sed 's!</tomcat-users>!<user userame...../> &!' file.xml > new.xml or
sed -i ... file.xmlto change file.xml directly.
For more complex transformation, a tool that has xml-parser would be the indicated choice.
0