
kushan
New User
Aug 10, 2009, 10:46 PM
Post #1 of 3
(4802 views)
|
Please help to solve my problem
|
Can't Post
|
|
Hi Everybody. i wrote a perl script to get the ip informaion of the interface in my server. Its working, but i only interest about the network address and its CIDR noration prefix. this my code for your refernce. #!/usr/bin/perl $command="/sbin/ifconfig eth0:0"; @filter=qx|$command |or die("Can't get info from ifconfig: ".$!); foreach(@filter){ if(/inet addr:([\d.]+)/){ # print "$1\t"; $para1=$1; } } foreach(@filter){ if(/Mask:([\d.]+)/){ # print "$1\n"; $para2=$1; } } #print "$para1\t"; #print "$para\n"; @CIDR=`/sbin/ipcalc-copy $para1 $para2| grep 'Network: '`; print "@CIDR\n"; this is working fine, its give me the result as ; Network: 192.168.0.0/28 11000000.10101000.00000000.0000 0000 But i need only the Decemial format, i dont need the binary format, can anybody help me to filter the 192.168.0.0/28 from above result. thank you Kushan
|