linux scripts to modify xml files

please suggest a way to use an available linux script which will grab two xml files and substitute some variables.

this script needs to be able to extract the private ip of the system, which is the substituted value for those variables.
bhomassAsked:
Who is Participating?
 
wesly_chenConnect With a Mentor Commented:
IP=`ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'`
sed  "s/\${ipaddress}/$IP/g"  server.xml  > server.xml_new
/bin/mv -f  server.xml_new   server.xml
0
 
wesly_chenCommented:
Please provide the xml file and which variables you want to substitute.
0
 
bhomassAuthor Commented:
they are some tomcat config files, like server.xml

that's say you have one tag that says

<Engine name="Catalina" defaultHost="localhost">

and I remove "localhost" and put in ${ipaddress} >

the script should sub ${ipaddress} with the numeric address like 192.168.1.210, after it reads the numerical address from ifconfig command.
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
bhomassAuthor Commented:
that's looks cool. I will try tomorrow.
0
 
wesly_chenCommented:
After
sed  "s/\${ipaddress}/$IP/g"  server.xml  > server.xml_new
verify server.xml_new before "/bin/mv -f"
0
 
bhomassAuthor Commented:
ifconfig gives me two addresses

one public, one private. identified as eth0 and eth1


as a result, when I ran

ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}

I get two ip addresses back. How do I get only one, the private one from eth1?
0
 
wesly_chenCommented:
ifconfig  eth1| grep 'inet addr:'| cut -d: -f2 | awk '{ print $1}
0
 
bhomassAuthor Commented:
worked like a charm!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.