\
Go Back   RightScale Forums > Linux/Unix

Reply
 
Thread Tools Display Modes
  #1  
Old 01-17-2009, 09:41 AM
mmflynn mmflynn is offline
Junior Member
Fog
 
Join Date: Dec 2008
Posts: 4
Default variable for local ip address

I feel silly that I haven't figured this out. I have a script that uses sed to update an xml file. I need to add the server's local ip address to this file. Neither $EC2_LOCAL_HOSTNAME or $EC2_PUBLIC_IP4 are acceptable -- I need the actual local IP address in the format x.x.x.x. I tried things like $ipaddr, but no luck.

Can someone tell me what variable I should use? I'm using a CentOS image from RightScript.

Thanks a bunch,
Mary
Reply With Quote
  #2  
Old 01-17-2009, 10:55 AM
mmflynn mmflynn is offline
Junior Member
Fog
 
Join Date: Dec 2008
Posts: 4
Default got it working

I figured it out -- instead of a named variable I use $(hostname -i):

Code:
sed -i "/searchtext/ a\ <value>$(hostname -i)</value>" myfile.xml
Reply With Quote
  #3  
Old 09-14-2009, 02:54 AM
venkat200 venkat200 is offline
Junior Member
Fog
 
Join Date: Sep 2009
Posts: 1
Default Ip-address

Quote:
Originally Posted by mmflynn View Post
I figured it out -- instead of a named variable I use $(hostname -i):

Code:
sed -i "/searchtext/ a\ <value>$(hostname -i)</value>" myfile.xml
.I found a site for ip-address details checking the site is Domain Host Search..
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 08:39 AM.