in reply to Back in the saddle...
#!/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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Back in the saddle...
by gnubbs (Beadle) on Apr 04, 2003 at 23:00 UTC |