Register
It is currently Tue Sep 23, 2014 6:24 pm

How to replace old ip with new ip in ipsec.conf?


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Sun Feb 03, 2013 8:24 pm   

Joined: Mon Oct 22, 2012 5:17 am
Posts: 2
I have dialup connection with dynamic ip address, i want to replace the old ip address with the new ip address in the ipsec.conf which is in the 18th line:
Code:
left=118.23.67.21

This is a code the print the new external ip address with each dialup connection:
Code:
EXTIF="ppp0"
IFCONFIG=/sbin/ifconfig
AWK=/usr/bin/awk
EXTIP="`$IFCONFIG $EXTIF 2>/dev/null | $AWK \
/$EXTIF/'{next}//{split($0,a,":");split(a[2],a," ");print a[1];exit}'`"
echo "$EXTIP"

how to use a code with one of cat, echo or sed commands to replace the above line with the ouput of this new ip address?


Top
 Profile  
 PostPosted: Sun Feb 03, 2013 11:35 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 548
hi,

with sed, change the whole 18th line to $var:
Code:
sed "18s/.*/$var/" UrFile
if your happy with this, add an -i.bak option.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP