Re: help on ip addr
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. To save you from re-inventing wheels... You don't need admin access to install most modules, just put them somewhere where you can script can access them and use lib. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: help on ip addr
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/
Re: help on ip addr
On Friday 26 October 2007 22:13, lists user wrote: Hello, 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. Just Ethernet NICs? What about Token Ring? DECNet? Wifi? IP6 tunneled through IP4? 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. No problem, just grap a copy of RFC1918. 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! Either use `/sbin/ifconfig` or the file /proc/net/arp (or write your own program to do what ifconfig does.) John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
help on ip addr
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/