Solved

linux scripts to modify xml files

Posted on 2011-09-07
8
419 Views
Last Modified: 2012-05-12
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.
0
Comment
Question by:bhomass
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 38

Expert Comment

by:wesly_chen
ID: 36500668
Please provide the xml file and which variables you want to substitute.
0
 

Author Comment

by:bhomass
ID: 36500714
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
 
LVL 38

Accepted Solution

by:
wesly_chen earned 250 total points
ID: 36500775
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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

Author Comment

by:bhomass
ID: 36500860
that's looks cool. I will try tomorrow.
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 36503063
After
sed  "s/\${ipaddress}/$IP/g"  server.xml  > server.xml_new
verify server.xml_new before "/bin/mv -f"
0
 

Author Comment

by:bhomass
ID: 36514459
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
 
LVL 38

Expert Comment

by:wesly_chen
ID: 36514488
ifconfig  eth1| grep 'inet addr:'| cut -d: -f2 | awk '{ print $1}
0
 

Author Comment

by:bhomass
ID: 36514561
worked like a charm!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question