close(STDIN); close(STDOUT); close(STDERR); Proc::Daemon::Init();
Proc::Daemon::Init(); something seems to have happened recently to bring out lots of cpan testers. I recently fixed up Date::Holidays::AU, which then got 39 passes from cpan testers, about 4 times more than the previous version.
Looking at other minor modules, quite a lot of them seem to be receiving good numbers of testers too.
very cool and much appreciated.
#!
/usr/bin/perl -w
use strict;
use FileHandle();
MAIN: {
my ($macAddress);
if (($^O eq 'linux') || ($^O eq 'solaris') || ($^O eq 'hpux') || ($^O eq 'aix')) {
$ENV{PATH} = '/sbin:/usr/sbin:/bin:/usr/bin';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
my ($ifconfig) = new FileHandle();
if (my $pid = $ifconfig->open('-|')) {
my ($buffer);
unless (defined $ifconfig->read($buffer, 8192)) {
die("Failed to read from ifconfig:$!");
}
if (($^O eq 'linux') || ($^O eq 'solaris')) {
# linux preceeded by HWaddr, solaris by ether
if ($buffer =~/(?:HWaddr +|ether +)([0-9A-Fa-f]{1,2}):([0-9A-Fa-f]{1,2}):([0-9A-Fa-f]{1,2}):([0-9A-Fa-f]{1,2}):( [ 0-9A-Fa-f]{1,2}):([0-9A-Fa-f]{1,2})/) {
$macAddress = formatMac($1, $2, $3, $4, $5, $6);
}
} elsif ($^O eq 'hpux') {
if ($buffer =~/^0x([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f ] {2})([0-9A-Fa-f]{2}) +$/) {
$macAddress = formatMac($1, $2, $3, $4, $5, $6);
}
} elsif ($^O eq 'aix') {
if ($buffer =~ / +([0-9A-Fa-f]{1,2})\.([0-9A-Fa-f]{1,2})\.([0-9A-Fa-f]{1,2})\.([0-9A-Fa-f]{1,2})\ .([0-9A-Fa-f]{1,2})\.([0-9A-Fa-f]{1,2}) +/) {
$macAddress = formatMac($1, $2, $3, $4, $5, $6);
}
}
unless ($ifconfig->close()) {
if (($^O eq 'linux') || ($^O eq 'solaris')) {
die("Failed to successfully execute 'ifconfig -a':$!");
} elsif ($^O eq 'hpux') {
die("Failed to successfully execute 'lanscan -a':$!");
} elsif ($^O eq 'aix') {
die("Failed to successfully execute 'netstat -ia':$!");
} else {
die("Unknown failure when determining mac address for '$^O'");
}
}
} elsif (defined $pid) {
eval {
if (($^O eq 'linux') || ($^O eq 'solaris')) {
unless (exec({ 'ifconfig' } 'ifconfig', '-a')) {
die("Failed to execute 'ifconfig -a':$!");
}
} elsif ($^O eq 'hpux') {
unless (exec({ 'lanscan' } 'lanscan', '-a')) {
die("Failed to execute 'lanscan -a':$!");
}
} elsif ($^O eq 'aix') {
unless (exec({ 'netstat' } 'netstat', '-ia')) {
die("Failed to execute 'netstat -ia':$!");
}
} else {
die("Failed to find a command to produce the mac address for '$^O'");
}
};
print STDERR $@;
exit(1);
} else {
die("Failed to fork:$!");
}
} elsif ($^O eq 'MSWin32') {
my ($ipconfig) = new FileHandle("ipconfig/all |");
unless ($ipconfig) {
die("Failed to 'ipconfig/all':$!");
}
my ($buffer);
unless (defined $ipconfig->read($buffer, 8192)) {
die("Failed to read from ipconfig:$!");
}
if ($buffer =~/^ +Physical Address(?:\. )+: ([0-9A-Fa-f]{1,2})\-([0-9A-Fa-f]{1,2})\-([0-9A-Fa-f]{1,2})\-([0-9A-Fa-f]{1,2})\ - ([0-9A-Fa-f]{1,2})\-([0-9A-Fa-f]{1,2})/m) {
$macAddress = formatMac($1, $2, $3, $4, $5, $6);
}
unless ($ipconfig->close()) {
die("Failed to close 'ipconfig/all':$!");
}
} else {
die("'$^O' cannot be recognised");
}
print "mac address is $macAddress\n";
}
sub formatMac {
my (@octets) = @_;
return join(':', map { sprintf('%.2X', hex($_)) } @_);
}
The saga over Dr Haneef just gets dumber and dumber. I'm trying hard to believe that our country has an effective and efficient police force, but with the curse of the internet and the ready access to information, this state of mind becomes harder and harder to maintain. According to local papers Dr Haneef, who has been released on bail due to the exceptional weak case the AFP have constructed, has now been detained in an immigration detention centre. Our federal Immigration minister, Kevin Andrews has decided that despite the release on bail, and that whole daft presumption of innocence thingy, Dr Haneef has failed the "character" test. The only possible conclusion i can come to is that he is implying that Dr Haneef is actually innocent and therefore unfit to be living in a land mostly populated by ex-convicts.