[mdlug] change ip in config

Dan Pritts danno at umich.edu
Sun Jun 26 21:30:49 EDT 2011


The trailing / is indeed required but the g isn't unless you needed multiple replacements per line. 

Sent from my iPhone

On Jun 24, 2011, at 11:08 AM, Tony Bemus <tony at bemushosting.com> wrote:

> Thanks Dan!  that worked*.  slight syntax error:
> sed "s/sip.server.host.*$/sip.server.host=${NEWIP}"
> Should be 
> sed "s/sip.server.host.*$/sip.server.host=${NEWIP}/g"
> 
> But this Helps Greatly !!!
> 
> Thank you again
> 
> Tony Bemus
> 
> 
> -----Original Message-----
> From: Dan Pritts <danno at umich.edu>
> Reply-to: MDLUG's Main discussion list <mdlug at mdlug.org>
> To: MDLUG's Main discussion list <mdlug at mdlug.org>
> Subject: Re: [mdlug] change ip in config
> Date: Fri, 24 Jun 2011 10:11:47 -0400
> 
> On Fri, Jun 24, 2011 at 09:42:02AM -0400, Tony Bemus wrote:
>> I need help with writing a script.  I need to update a config file every
>> time the computer boots.  I got the part to have it run at boot, but I
>> need help with writing the script.
>> 
>> I need to get the current eth0 ip address then replace it in a config
>> file.  My googleing found this to get the ip:
>> 
>>    # ip addr list eth0 |grep "inet " |cut -d' ' -f6|cut -d/ -f1
>> 
>> and that out put is the correct IP with just the ip address
>> "10.112.5.142".  Now I need to have it replace the IP address in in a
>> config file line:
>> 
>>    sip.server.host=10.112.5.142
>> 
>> I guess it could replace the line with a new line "sip.server.host=(ip)"
>> replacing the (ip).  
> 
> NEWIP=`ip addr list eth0 |grep "inet " |cut -d' ' -f6|cut -d/ -f1`
> sed "s/sip.server.host.*$/sip.server.host=${NEWIP}" < configfyle > /tmp/configfyle.tmp.$$
> mv /tmp/configfyle.tmp.$$ configfyle
> 
> this does no error checking and is not appropriate for serious
> production use without adding some.
> 
> I'd also check whether your sip software can accept the parameter
> on the command line or from an environment variable.  It would
> probably be more reliable to do it that way.
> 
> danno
> --
> dan pritts
> danno at umich.edu
> 734-929-9770
> _______________________________________________
> mdlug mailing list
> mdlug at mdlug.org
> http://mdlug.org/mailman/listinfo/mdlug
> 
> _______________________________________________
> mdlug mailing list
> mdlug at mdlug.org
> http://mdlug.org/mailman/listinfo/mdlug



More information about the mdlug mailing list