in reply to Back in the saddle...

gnubbs,
Perhaps you want to try the following instead. It may be a little easier to use.

#!/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

    That was a great bit of advice. Didn't even think of using netstat. Something along these lines is probably what will end up in the script, but hopefully I will still find out what I was doing wrong in the original.

    thanks,
    gnubbs