Try this:

#!/usr/bin/perl

@info = `ifconfig`;
foreach $line(@info){
        if ($line =~ /inet addr/){
                $line =~ s/(.*)(:)(.*)(\ )(.*)(:)(.*)/\3/;
                print $line;
        }
}

I'm sure you could do some grep stuff on this as well:

ifconfig | grep inet | sed 's/inet\ addr://' | awk {'print $1'}

Good Luck

Mike

adrian walters <[EMAIL PROTECTED]>@redhat.com on 12/05/2000 12:22:16
PM

Please respond to [EMAIL PROTECTED]

Sent by:  [EMAIL PROTECTED]


To:   [EMAIL PROTECTED]
cc:
Subject:  how do the ip of a PPP connection?


i am trying to write a little shell script that will
update my dns on a remote machine every 10 minutes,
using nsupdate. the problem is I need to get the IP
address of my dsl connection, but i can't seem to find
a way to parse the output from ifconfig. my connection
uses PPPOE. i would be very appreciative if one of the
perl gurus would point me in the right direction.


here is the output from ifconfig, the only thing i
need is the inet addr.

ppp0      Link encap:Point-to-Point Protocol
          inet addr:138.89.32.190  P-t-P:10.5.1.1
Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST
MTU:1492  Metric:1
          RX packets:57247 errors:0 dropped:0
overruns:0 frame:0
          TX packets:40905 errors:0 dropped:0
overruns:0 carrier:0
          collisions:0 txqueuelen:10

__________________________________________________
Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products.
http://shopping.yahoo.com/



_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list






_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to