Solved

linux scripts to modify xml files

Posted on 2011-09-07
8
415 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

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 …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

734 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