- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: netmask
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2006 10:40 AM
06-30-2006 10:40 AM
I want to see the subnet value in decimal format such 255.255.255.0 etc.
"$ifconfig lan0" command gives me output in hexadecimal format.
Can someone suggest how to convert these hexadecimal values into decimal format (such as 255.255.255.0 format ) ?
Thanks in advance.
Shiv
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2006 11:16 AM
06-30-2006 11:16 AM
SolutionEssentialy after setting the input base to 16, you then enter each 2-digit hex pair and immediately the decimal equivalant is output.
e.g.
bc
ibase=16
>FF
255
>FF
255
>FF
255
>00
0
q # exits bc
Man bc for details.
You can also code fancy Perl or bc scripts to translate the entire 32-bit hex value into decimal octets but I'm not smart enough to do that (or maybe I think you should do it yourself; after all, you need it, I don't).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2006 11:17 AM
06-30-2006 11:17 AM
Re: netmask
var=`ifconfig $lan |grep inet|awk '{print $4}'`
oct1=0x`echo $var | cut -c 1-2`
oct2=0x`echo $var | cut -c 3-4`
oct3=0x`echo $var | cut -c 5-6`
oct4=0x`echo $var | cut -c 7-8`
printf "Subnet: %d.%d.%d.%d" $oct1 $oct2 $oct3 $oct4
this is giving what we want.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2006 11:22 AM
06-30-2006 11:22 AM
Re: netmask
it is coming to 255.255.254.0 correct ?
after my college day first time i am required to use it.
Is there any direct command in hpux so that we can get netmask in 255.255.... etc format ?
Regards,
Shiv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2006 11:29 AM
06-30-2006 11:29 AM
Re: netmask
set the variale "$lan"
$lan=lan0
othervise use lan0 directly:
=============================
var=`ifconfig lan0 |grep inet|awk '{print $4}'`
oct1=0x`echo $var | cut -c 1-2`
oct2=0x`echo $var | cut -c 3-4`
oct3=0x`echo $var | cut -c 5-6`
oct4=0x`echo $var | cut -c 7-8`
printf "Subnet: %d.%d.%d.%d" $oct1 $oct2 $oct3 $oct4
============================
when i ran this:
$sh ifconfig_test
Subnet: 255.255.254.0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2006 11:36 AM
06-30-2006 11:36 AM
Re: netmask
Regards,
Shiv