Hi there
I am running a script which requires the input of a MAC address from the user and was loooking for a regex that will verify the user has inputted a full 12 digit valid MAC with colons
Ive seen a few on some sites that look huge and was wondering if anybody had a one liner (or as... (21 Replies)
Hello:
I'm trying to extracta a matching substring from a string using regular expression. I need to extract the date part of any giving string.
All input string will have date in YYYYMMDD format in them, but it can be anywhere in the string.
Eg.
The_Mummy20080125_New... (2 Replies)
CA_RELEASE has a value of 6. I need to check if that this is a numeric value. if not error.
source $CA_VERSION_DATA
if * ]
then
echo "CA_RELESE $CA_RELEASE is invalid"
exit -1
fi
+ source /etc/ncgl/ca_version_data
++ CA_PRODUCT_ID=samxts
++ CA_RELEASE=6
++ CA_WEEK_NO=7
++... (3 Replies)
Hi all,
How am I read a file, find the match regular expression and overwrite to the same files.
open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat";
open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat";
while (<DESTINATION_FILE>)
{
# print... (1 Reply)
Hi,
Am using FreeBSD7.4/i386
During IPv6 configuration, I added the following in rc.conf as
Restarted IPv6 network using /etc/rc.d/network_ipv6 restart..
My problem is I need to set link local IPv6 address auto-configured..
Is my proceeding right??
I feel something missing to make... (0 Replies)
hi
i am trying to extract some specific data out of a text file using regular expressions with shell script
that is using a multiline grep .. and the tool i am using is pcregrep so that i can get compatibility with perl's regular expressions
for a sample data like this, i am trying to grab... (6 Replies)
Hello All,
I'm trying to extract the lines between two consecutive elements of an array from a file.
My array looks like:
problem_arr=(PRS111 PRS213 PRS234)
j=0
while } ]
do
k=`expr $j + 1`
sed -n "/${problem_arr}/,/${problem_arr}/p" problemid.txt
---some operation goes... (11 Replies)
Hi all, I have a large fasta (dna sequence) file. I would like to extract a portion of the header as well as the sequence (line below the header).
Input:
Output:
All accession values (the term I want to preserve, which is the string including and directly following "GL") are different, but I... (8 Replies)
Hi All,
Would anyone know how to modify the below, so only the IPv6 address (red) is printed, please?
(in other words, what's between inet6 and the / sign)
ipv6=`/sbin/ifconfig lo0:5 inet6 | grep 'inet6'`
print $ipv6
Currently the output of the above script is:
inet6... (7 Replies)
Discussion started by: chatguy
7 Replies
LEARN ABOUT DEBIAN
paranoid::network::ipv6
Paranoid::Network::IPv6(3pm) User Contributed Perl Documentation Paranoid::Network::IPv6(3pm)NAME
Paranoid::Network::IPv6 - IPv6-related functions
VERSION
$Id: IPv6.pm,v 0.1 2012/05/29 21:37:44 acorliss Exp $
SYNOPSIS DESCRIPTION
This module contains a few convenience functions for working with IPv6 addresses.
By default only the subroutines themselves are imported. Requesting :all will also import the constants as well.
SUBROUTINES /METHODS
ipv6NetConvert
@net = ipv6NetConvert($netAddr);
This function takes an IPv4 network address in string format and converts it into and array of arrays. The arrays will contain the base
network address, the broadcast address, and the netmask, each split into native 32bit integer format chunks. Each sub array is essentially
what you would get from:
@chunks = unpack 'NNNN', inet_pton(AF_INET6, '::1');
using '::1' as the sample IPv6 address.
The network address must have the netmask in CIDR format. In the case of a single IP address, the array with only have one subarray, that
of the IP itself, split into 32bit integers.
Passing any argument to this function that is not a string representation of an IP address (including undef values) will cause this
function to return an empty array.
ipv6NetPacked
@net = ipv6NetPacked('fe80::/64');
This function is a wrapper for ipv6NetConvert, but instead of subarrays each element is the packed (opaque) string as returned by
inet_pton.
ipv6NetIntersect
$rv = ipv6NetIntersect($net1, $net2);
This function tests whether an IP or subnet intersects with another IP or subnet. The return value is essentially boolean, but the true
value can vary to indicate which is a subset of the other:
-1: destination range encompasses target range
0: both ranges do not intersect at all
1: target range encompasses destination range
The function handles the same string formats as ipv6NetConvert, but will allow you to test single IPs in integer format as well.
CONSTANTS
These are only imported if explicity requested or with the :all tag.
MAXIPV6CIDR
Simply put: 64. This is the largest CIDR notation supported in IPv6.
IPV6REGEX
Regular expression:
qr/
:(?::[abcdefd]{1,4}){1,7} |
[abcdefd]{1,4}(?:::?[abcdefd]{1,4}){1,7} |
(?:[abcdefd]{1,4}:){1,7}:
/smix;
You can use this for validating IP addresses as such:
$ip =~ m#^@{[ IPV6REGEX ]}$#;
or to extract potential IPs from extraneous text:
(@ips) = ( $string =~ m#(@{[ IPV6REGEX ]})#g);
IPV6CIDRRGX
Regular expression:
qr#(@{[ IPV6REGEX ]})(?:/(d+))?#sm
By default this will extract an IP or CIDR notation network address:
($net, $mask) = ( $ip =~ m#^@{[ IPV6CIDRRGX ]}$# );
In the case of a simple IP address $mask will be undefined.
IPV6BASE
This is the ordinal index of the base network address as returned by ipv6NetConvert.
IPV6BRDCST
This is the ordinal index of the broadcast address as returned by ipv6NetConvert.
IPV6MASK
This is the ordinal index of the network mask as returned by ipv6NetConvert.
DEPENDENCIES
o Paranoid
o Paranoid::Network::Socket
BUGS AND LIMITATIONS AUTHOR
Arthur Corliss (corliss@digitalmages.com)
LICENSE AND COPYRIGHT
This software is licensed under the same terms as Perl, itself. Please see http://dev.perl.org/licenses/ for more information.
(c) 2012, Arthur Corliss (corliss@digitalmages.com)
perl v5.14.2 2012-05-29 Paranoid::Network::IPv6(3pm)