Created
July 10, 2015 04:37
-
-
Save s3itz/2cc79134aa58d8a9d1ca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# Written by Claudio Ramirez <[email protected]> | |
# A small wrapper around Solaris ifconfig to get rid of the awful | |
# hexadecimal netmask (ffffff00 => 255.255.255.0) | |
# | |
# Modified to address change in filesystem | |
use strict; | |
use warnings; | |
my @output = `/sbin/ifconfig @ARGV`; | |
foreach my $output (@output) { | |
if ($output =~ /\bnetmask\s+(\w\w\w\w\w\w\w\w)\b/) { | |
my $pre_nm = $` . "netmask "; | |
my $nm = $1; | |
my $post_nm = $'; | |
$nm =~ /(\w\w)(\w\w)(\w\w)(\w\w)/; | |
my $bit2 = $2; | |
my $bit3 = $3; | |
my $bit4 = $4; | |
my $num2 = hex($bit2); | |
my $num3 = hex($bit3); | |
my $num4 = hex($bit4); | |
$nm = "255.$num2.$num3.$num4"; | |
$output = $pre_nm . $nm . $post_nm; | |
} | |
} | |
print @output; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment