Hello, You should do it, maybe with a regex like that: perl -e '$/=undef; $ips = `ifconfig`; while($ips =~ /(?:^|\n)(\S+)[^\n] +(?:\n\s[^\n])*\n\s+inet addr:(\S+)/gm) { print "$1 is $2\n";}'
-- tfe http://tfeserver.homelinux.com On 27 oct, 07:13, [EMAIL PROTECTED] (Lists User) wrote: > Hello, > > I want to do the things below: > > a) get all binded IPs on a redhat linux os.there are maybe more than > one IP,like eth0,eth1,eth0:1 etc. > > b) for each IP,I need to know if it's a private network address (like > 192.168.0.1) or a public network address. > > for the first problem I can read something from > /etc/sysconfig/network-script/ifcfg-eth*, or code with @ips = > `/sbin/ifconfig` and use regex to capture the IPs.But I don't think > these are the best ways. > > I don't like to use any CPAN module,b/c I'm not admin user,don't have > privileges to install those modules. > > Can you show me a good way? Thanks! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/