Solved

linux scripts to modify xml files

Posted on 2011-09-07
8
401 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
  • 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
 

Author Comment

by:bhomass
ID: 36500860
that's looks cool. I will try tomorrow.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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 Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now