FW: regex needed

From: Manav Mathur (manavm_at_mahindrabt.com)
Date: 01/19/05


To: "Beginners@Perl. Org" <beginners@perl.org>
Date: Wed, 19 Jan 2005 21:45:45 +0530


Still cant get to you chris

-----Original Message-----
From: Manav Mathur [mailto:manavm@mahindrabt.com]
Sent: Wednesday, January 19, 2005 9:44 PM
To: Chris Knipe
Subject: RE: regex needed

Sure thing. I have put my updated scripts in perl.org. As I love making
mistakes :( , you must refer to the latest post to see the working script. I
have also included the example. However, a 9 hours ago, I was not able to
get thru your mail id. SO had to post it in the group.

Manav

|-----Original Message-----
|From: Chris Knipe [mailto:savage@savage.za.org]
|Sent: Wednesday, January 19, 2005 9:38 PM
|To: Manav Mathur
|Subject: Re: regex needed
|
|
|Hi Manav,
|
|Thank you for the effort!!! We have been experiencing SERIOUS routing
|abnormalities on the network and we are currently re thinking the entire
|setup. We should begin the new setup in a test rig later tonight.
|
|We will still need to change MASSIVE amounts of routes manually
|(unfortunately), but for now, the router that I used to test the script on
|is toast. I'll keep the script with your updates in place and tomorrow or
|so when we start to play arround, I'll give you a shout again if there is
|still errors.
|
|If I'm lucky, I should be able to manage most of the routing via
|OSPF / BGP
|and hence, I'll prob just need to update the routing split (Local vs
|International) once a day or something like that...
|
|I'll keep you posted!!
|
|--
|Chris.
|
|
|
|
|----- Original Message -----
|From: "Manav Mathur" <manavm@mahindrabt.com>
|To: "Chris Knipe" <savage@savage.za.org>; <beginners@perl.org>
|Sent: Wednesday, January 19, 2005 9:28 AM
|Subject: RE: regex needed
|
|
|>
|> Chris , cant get to you.
|>
|> 1) Use $RouteArray[2] instead of $RouteArray['2']
|> 2) POst me the 11th route entry
|>
|> |-----Original Message-----
|> |From: Chris Knipe [mailto:savage@savage.za.org]
|> |Sent: Tuesday, January 18, 2005 7:55 PM
|> |To: beginners@perl.org
|> |Subject: Re: regex needed
|> |
|> |
|> |Hi Randy,
|> |
|> |Ok thank you very much. This works :) The problem now, is that I have
|> |never before in my life worked with hashes...
|> |
|> |I have now looped the route list, and it is saved in the hash.
|Do I loop
|> |the hash again now (dumping all data) and then put in
|> |comparisions? I'm not
|> |100% on how to work with this further now to check which route is on the
|> |interface that I actually want to delete...
|> |
|> |I want to achieve something like
|> |
|> |if (($data{interface} eq "National Gateway") && ($data{gateway} =~
|> |m/165\.(165|146)\.0\.[0-8]/)) {
|> | #work with $data{rule};
|> |}
|> |
|> |--
|> |Chris.
|> |
|> |
|> |
|> |
|> |
|> |
|> |
|> |----- Original Message -----
|> |From: "Randy W. Sims" <ml-perl@thepierianspring.org>
|> |To: "Chris Knipe" <savage@savage.za.org>
|> |Cc: <beginners@perl.org>
|> |Sent: Tuesday, January 18, 2005 4:04 PM
|> |Subject: Re: regex needed
|> |
|> |
|> |> Chris Knipe wrote:
|> |>> Lo everyone,
|> |>>
|> |>> Can someone please give me a regex to parse the following... Flags:
|> X -
|> |>> disabled, I - invalid, D - dynamic, J - rejected,
|> |>> C - connect, S - static, r - rip, o - ospf, b - bgp
|> |>> # DST-ADDRESS G GATEWAY DISTANCE INTERFACE
|> |>> 0 S 0.0.0.0/0 r 198.19.0.2 1 SERVER-CORE
|> |>> 1 S 196.0.0.0/8 r 165.146.192.1 1 National Gateway
|> |>> 2 DC 198.19.1.0/24 r 0.0.0.0 0 WIRELESS-CORE
|> |>> 3 Ib 198.19.0.0/24 u 0.0.0.0 200 (unknown)
|> |>> 4 DC 198.19.0.0/24 r 0.0.0.0 0 SERVER-CORE
|> |>> 5 DC 192.168.1.0/24 r 0.0.0.0 0 INTERNAL-CORE
|> |>> 6 DC 165.146.192.1/32 r 0.0.0.0 0 National Gateway
|> |>> [admin@wsmd-core] >
|> |>>
|> |>>
|> |>> I want the regex to return the rule number for all route
|> |entries that is
|> |>> static (S Flag) on Interface "National Gateway". For added
|> |security, I'd
|> |>> like it if the regex will also only return true if the gateway
|> |address is
|> |>> part of 165.165.0.0/8 or 165.146.0.0/8
|> |>>
|> |>> Basically, I need to use the rule number in another command to
|> |delete the
|> |>> route entry... So I presume I'll need to extract it via the regex
|> |>
|> |> If it's a fixed width data format, its better (easier for you,
|> |faster for
|> |> perl) to break up the string with C<substr>:
|> |>
|> |> #!/usr/bin/perl
|> |>
|> |> use strict;
|> |> use warnings;
|> |>
|> |>
|> |> while (defined( my $line = <DATA> )) {
|> |> chomp( $line );
|> |>
|> |> my %data;
|> |> $data{rule} = substr( $line, 0, 2 );
|> |> $data{flags} = substr( $line, 3, 2 );
|> |> $data{dest_ip} = substr( $line, 6, 18 );
|> |> $data{g} = substr( $line, 25, 1 );
|> |> $data{gateway} = substr( $line, 27, 16 );
|> |> $data{distance} = substr( $line, 43, 8 );
|> |> $data{interface} = substr( $line, 52 );
|> |>
|> |> # cleanup, stripping spaces
|> |> $data{$_} =~ s/^\s+|\s+$//g
|> |> for keys %data;
|> |>
|> |> # reformat or reinterpret data
|> |> $data{flags} = [ split( //, $data{flags} ) ];
|> |>
|> |> use Data::Dumper;
|> |> print Dumper( \%data );
|> |> }
|> |>
|> |>
|> |>
|> |> __END__
|> |> 0 S 0.0.0.0/0 r 198.19.0.2 1 SERVER-CORE
|> |> 1 S 196.0.0.0/8 r 165.146.192.1 1 National Gateway
|> |> 2 DC 198.19.1.0/24 r 0.0.0.0 0 WIRELESS-CORE
|> |> 3 Ib 198.19.0.0/24 u 0.0.0.0 200 (unknown)
|> |> 4 DC 198.19.0.0/24 r 0.0.0.0 0 SERVER-CORE
|> |> 5 DC 192.168.1.0/24 r 0.0.0.0 0 INTERNAL-CORE
|> |> 6 DC 165.146.192.1/32 r 0.0.0.0 0 National Gateway
|> |>
|> |>
|> |
|> |
|> |--
|> |To unsubscribe, e-mail: beginners-unsubscribe@perl.org
|> |For additional commands, e-mail: beginners-help@perl.org
|> |<http://learn.perl.org/> <http://learn.perl.org/first-response>
|> |
|> |
|>
|>
|> *********************************************************
|> Disclaimer:
|>
|> This message (including any attachments) contains
|> confidential information intended for a specific
|> individual and purpose, and is protected by law.
|> If you are not the intended recipient, you should
|> delete this message and are hereby notified that
|> any disclosure, copying, or distribution of this
|> message, or the taking of any action based on it,
|> is strictly prohibited.
|>
|> *********************************************************
|> Visit us at http://www.mahindrabt.com
|>
|>
|> --
|> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
|> For additional commands, e-mail: beginners-help@perl.org
|> <http://learn.perl.org/> <http://learn.perl.org/first-response>
|>
|>
|>
|

*********************************************************
Disclaimer:

This message (including any attachments) contains
confidential information intended for a specific
individual and purpose, and is protected by law.
If you are not the intended recipient, you should
delete this message and are hereby notified that
any disclosure, copying, or distribution of this
message, or the taking of any action based on it,
is strictly prohibited.

*********************************************************
Visit us at http://www.mahindrabt.com



Relevant Pages

  • Re: Nav Bars
    ... I found that script handy when I was doing a shopping cart with very long ... > Thanks very much Chris. ... >> you can use either a frame or a static layer. ...
    (microsoft.public.frontpage.client)
  • RE: regex needed
    ... Ok Chris. ... route entries, there's a space at the beginning whereas for some there aint ... ||Subject: Re: regex needed ...
    (perl.beginners)
  • Re: sed problem: variables countaining special symbols
    ... Chris F.A. Johnson wrote: ... My script is falling over with a sed problem. ... That's bacause $NPASS contains a slash. ...
    (comp.unix.shell)
  • Re: Open Source GIS - Need Advice Please
    ... you may rey avismap gis engine. ... where he want to go and gets the route planned. ... PHP: To write the scripts to communicate with the PostGIS / User + ... A script in PHP which captures the data and then echo the image ...
    (comp.infosystems.gis)
  • Re: 3 NIC, 2 ADSL, Help me
    ... Here is the script: ... # we are going to create Routing for multiple uplinks/providers. ... ip route add default via $P1 table T1 ... 32760: from 192.168.1.1 lookup T1 ...
    (comp.os.linux.networking)