#!/usr/bin/perl -w use strict; my $ip_address; open (NETSTAT,"/usr/bin/netstat -in |") or die "Unable to execute nets +tat"; while (<NETSTAT>) { next unless (/^ec0/); my @fields = split; $ip_address = $fields[3]; } print "$ip_address\n";
I took the liberty of changing the ifconfig to a netstat because it is much easier to parse. This code can be greatly simplified, but since you say you are getting back in the saddle - I wanted to make it as clear as possible what I was doing.
Cheers - L~R
In reply to Re: Back in the saddle...
by Limbic~Region
in thread Back in the saddle...
by gnubbs
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |