On Tue, 2002-10-15 at 20:59, Bret Hughes wrote:
> On Tue, 2002-10-15 at 16:09, Mark wrote:
> > On Tuesday 15 October 2002 01:05 pm, Bret is done writ:
> > <snip>
> > > have been working with awk lately and this seems a good time for it.  
> > <snip>
> > And then..the script:
> > 
> > BEGIN {
> > #  set the variables for the address change
> > # * * * * * * * * * * * * * * * * * * * * * * * * 
> > #    Make sure you leave the $ at the end of the oldip address
> > # to take care of the situation where the last octet is less thatn
> > # three digits in decimal   
> > 
> > Not necessary.
> > # * * * * * * * * * * * * * * * * * ** * * * * *     
> > 
> > #    oldip="192.168.0.13$" changed to below
> >     oldip="192.168.0.13"
> >     newip="192.168.0.123"
> > }
> 
> Thanks for the clean up.  I am certainly not an awk guru but it's nice
> to see I was on the right track :)
> 
> when I ran the code I sent using sub(oldip,newip) as you suggest,
> without the $ end of line placeholder, it changed addresses like
> 192.168.0.131 to 192.168.0.1231.  I will run run your code but assuming
> that it works, wy does it and mine did not?  Is there some magic in
> gsub?
> 

Turns out this has the same bug that I fixed with the $ but shold
probably be a end of word char \> maybe?


> > {
> > # increment the serial number which should be the line directly below
> > # the SOA line
> >    if ($0 ~ /SOA/) {
> >       print;        
> >       getline;
> >       ser_no = $(1);
> >       restofline = substr( $0, index( $0, /;/ ) + 1); # get rest of line
> 
> This looks like a good idea and I will try to figurout how it works :)

using my data this does not work

here is what I get using the following data:

[bhughes@compaq2 bin]$ head -20 brets.elevating.com 
@       IN      SOA     compaq2.brets.elevating.com. [EMAIL PROTECTED] (
                        2001062040
                        3600
                        900
                        1209600
                        43200 )
gateway1                IN      A       192.168.0.4
compaq3         IN      A       192.168.0.14
tulfw1          IN      A       192.168.0.1
tulfs01         IN      CNAME   compaq2.brets.elevating.com.
compaq1         IN      A       192.168.0.3
labgdu1         IN      A       192.168.0.133
vpn29           IN      A       192.168.0.29
vpn28           IN      A       192.168.0.28
zenon.brets.elevating.com.      IN      A       192.168.0.130
webserver               IN      A       192.168.0.15
@               IN      MX      5       gateway1.brets.elevating.com.
@               IN      NS      compaq2.brets.elevating.com.
bretdell                IN      A       192.168.0.128
compaq2         IN      A       192.168.0.13


I copied your code to changeips1 and ran it after fixing a non commented
comment and an extra paren 

[bhughes@compaq2 bin]$ awk -f changeips1 brets.elevating.com |head -20
@       IN      SOA     compaq2.brets.elevating.com. [EMAIL PROTECTED] (
                                200106204101062040      ## not good
                        3600
                        900
                        1209600
                        43200 )
gateway1                IN      A       192.168.0.4
compaq3         IN      A       192.168.0.14
tulfw1          IN      A       192.168.0.1
tulfs01         IN      CNAME   compaq2.brets.elevating.com.
compaq1         IN      A       192.168.0.3
labgdu1         IN      A       192.168.0.1233         ##not good either
vpn29           IN      A       192.168.0.29
vpn28           IN      A       192.168.0.28
zenon.brets.elevating.com.      IN      A       192.168.0.1230 ##nope
webserver               IN      A       192.168.0.15
@               IN      MX      5       gateway1.brets.elevating.com.
@               IN      NS      compaq2.brets.elevating.com.
bretdell                IN      A       192.168.0.128
compaq2         IN      A       192.168.0.123   ##This is the one I wanted looks good

here is what my original code does

[bhughes@compaq2 bin]$ awk -f changeips brets.elevating.com |head -20
@       IN      SOA     compaq2.brets.elevating.com. [EMAIL PROTECTED] (
                        2001062041      ## desired result
                        3600
                        900
                        1209600
                        43200 )
gateway1                IN      A       192.168.0.4
compaq3         IN      A       192.168.0.14
tulfw1          IN      A       192.168.0.1
tulfs01         IN      CNAME   compaq2.brets.elevating.com.
compaq1         IN      A       192.168.0.3
labgdu1         IN      A       192.168.0.133
vpn29           IN      A       192.168.0.29
vpn28           IN      A       192.168.0.28
zenon.brets.elevating.com.      IN      A       192.168.0.130 
webserver               IN      A       192.168.0.15
@               IN      MX      5       gateway1.brets.elevating.com.
@               IN      NS      compaq2.brets.elevating.com.
bretdell                IN      A       192.168.0.128
compaq2         IN      A       192.168.0.123  ## only ip changed. desired result


I suspect that the zone files ( built by webmin modifying those that
were modified by linuxconf way back that were built by me even further
back must be different from those your code was designed for.  Either
that or even gurus should test thier code before posting it :)

Later, 
Bret



-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to