Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting your internal IP with perl, mac and linux
#1
As always brought to you by my blog http://bsdpunk.blogspot.com:

For Mac:
PHP Code:
#!/opt/local/bin/perl
my @ifconfig = `ifconfig`;
my $inetter qr/(inet \d+\.\d+\.\d+.\d+)/;
foreach (@
ifconfig) {
my $line $_;
        if (
$line =~ $inetter){
                        print $&.
"\n";
        }

For Linux:

PHP Code:
#!/usr/bin/perl
my @ifconfig = `ifconfig`;
my $inetter qr/(inet addr:\d+\.\d+\.\d+.\d+)/;
foreach (@
ifconfig) {
my $line $_;
        if (
$line =~ $inetter){
                        print $&.
"\n";
        }



If you want this broken down line by line, I do that here:
http://bsdpunk.blogspot.com/2009/07/perl...al-ip.html
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Compile Error in Perl liveproject101 0 1,154 04-12-2013, 03:08 AM
Last Post: liveproject101
  [Perl] IRC Bot wchar_t 26 12,861 08-20-2012, 01:40 PM
Last Post: Trump
  Perl Ebook ven0m 2 1,625 05-04-2012, 08:14 AM
Last Post: ven0m
  Help with a program written in perl Rodman42866 1 1,530 03-09-2012, 03:16 AM
Last Post: AceInfinity
  HTML perl script AceInfinity 5 2,409 12-03-2011, 11:35 PM
Last Post: Closed Account

Forum Jump:


Users browsing this thread: 1 Guest(s)