Re: little awk question

Jon Ruano <[email protected]> Sun, 30 Jul 2006 15:25:48 +0200
Newsgroups gmane.network.toolmakers
Message-ID <[email protected]>
Hey, your solution is *way* more elegant.

Regarding my changes to the main file, most of them are related to =20
route-map and distribute-list, and some for snmp-server and ntp lines.

These are the ones not explicitely route-map related (some of these =20
could be grouped too):

# ruanoj: found a route-map reference (unsuppress-map)
/^ neighbor [a-z0-9\.-]+ unsuppress-map / {
   ref[router " route-map " $4] =3D 1;
   next;
}

# ruanoj: found a route-map in aggregation
# aggregate-address a.a.a.a b.b.b.b summary-only attribute-map =20
routemap001
/^ aggregate-address [0-9.]+ [0-9.]+ summary-only attribute-map / {
   ref[router " route-map " $6] =3D 1;
   next;
}

# ruanoj distribute-list prefix reference into router
/^ distribute-list prefix / {
   ref[router " prefix-list " $3] =3D 1;
   next;
}

# ruanoj distribute-list (simple) reference
/^ distribute-list / {
   ref[router " access-list " $2] =3D 1;
   next;
}

# ruanoj
#snmp-server community mycommunity view saveconfig RW 61
/^snmp-server community [a-z0-9\.-]+ view [a-z0-9\.-]+ R. / {
   ref[router " access-list " $7] =3D 1;
   next;
}

# ruanoj
#snmp-server community mycommunity RO 7
/^snmp-server community [a-z0-9-]+ R. / {
   ref[router " access-list " $5] =3D 1;
   next;
}

# ruanoj
# ntp access-group peer
/^ntp access-group peer / {
   ref[router " access-list " $4] =3D 1;
   next;
}


# ruanoj: found a community-list reference
/^ match community / {
   cur =3D 3;
   while ( cur <=3D NF ) {
      ref[router " community-list " $cur] =3D 1;
      cur++;
   }
   next;
}


On Jul 30, 2006, at 4:10 PM, Yuval Ben-Ari wrote:
>
> Yes, that should work.
> I think I found another way:
>
> /^ .* route-map / {
>   match($0, /route-map ([A-Za-z0-9_\-]+)/, arr);
>   ref[router " route-map " arr[1]] =3D 1;
>   next;
> }
>
> P.S
> It is a shame that we will each do the same work on his own.
> Did you do many changes in filter_audit.awk file ?
> I plan to finish my changes and send to the author so it can be
> published as newer version.
> I also try to be as reliable to the original as possible.
>
> Yuval
>