Translate

Image of Android Wireless Application Development
Image of Operating System Concepts
Image of RHCE Red Hat Certified Engineer Linux Study Guide (Exam RH302) (Certification Press)
Image of Linux Kernel Development (3rd Edition)

Using Perl Net::IP to Manipulate IPv4 Addresses

In a previous post, I demonstrated a Korn shell script which determined the subnet mask for a range of IPv4 addresses. Perl has a module called Net::IP which provides a number of functions which can be used to manipulate IPv4 (and also IPv6) addresses to provide the same information and a lot more besides. For example, the following code outputs a lot of information about a classless prefix: use Net::IP; my $ip = new Net::IP (‘10.1.1.0/24’) or die (Net::IP::Error()); print ("IP : ".$ip->ip()."n"); print ("Sho : ".$ip->short()."n"); print ("Bin : ".$ip->binip()."n"); print ("Int : ".$ip->intip()."n"); print ("Mask: ".$ip->mask()."n"); print ("Last:

Calculate IPv4 Subnet Mask and Prefix

Here is a simple ksh93 script which I recently wrote to calculate the subnet mask and prefix when given a range of IPv4 addresses. It makes use of the bit manipulation facilities available in ksh93. #!/bin/ksh93 [[ $# != 2 ]] && { echo "Usage: $0 ipaddress1 ipaddress2" exit 1 } SaveIFS=$IFS IFS="./" typeset -a IParr1=($1) typeset -a IParr2=($2) IFS=$SaveIFS typeset -i2 ip11=${IParr1[0]} typeset -i2 ip12=${IParr1[1]} typeset -i2 ip13=${IParr1[2]} typeset -i2 ip14=${IParr1[3]} typeset -i2 ip21=${IParr2[0]} typeset -i2 ip22=${IParr2[1]} typeset -i2 ip23=${IParr2[2]} typeset -i2 ip24=${IParr2[3]} mask=0; match=1 for ((arr=1; arr < 5; arr++)) do binary_value1="" binary_value2="" for ((b=7; b >= 0;

Use Wget? Try Aria2

If you currently use wget to download files via the command line, you should have a look at aria2. The aria2 utility is a lightweight multi-protocol & multi-source download utility which supports HTTP/HTTPS, FTP, BitTorrent and Metalink and can be manipulated via built-in JSON-RPC and XML-RPC interfaces. Unlike the original aria utility which has a GTK+ interface; aria2 provides only a command-line interface and thus has lower resource requirements. Aria2 tries to utilize your maximum download bandwidth. It has two distinctive features: (1) aria2 can download a file from several URIs(HTTP(S)/FTP/BitTorrent) and (2) If you give aria2 a list of

Fedora 17 "Error: Protected multilib versions"

Getting an error like the following when installing a package or group of packages on your Fedora 17 system? Error: Protected multilib versions: XXXXXXXX.fc17.i686 != XXXXXXXX.fc17.x86_64 This is because whenever you have both 32 and 64 bit versions of a package, they must be of the same version and release. The error message is showing you that the 32 bit version-release of the package does not equal (!=) the 64 bit version-release. You either need to update the 32 bit version to match the 64 bit version, or erase the 32 bit version to get rid of this error. While