I am getting SNMP data for a system that I manage, and need to put together reports monthly. The database stores the IP address information in Hex... so an example would be "C0 A8 01 01"
What would be the best way to convert this to a dotted decimal format: "192.168.1.1"?
Any ideas or help would be very much appreciated.
Thanks,
--Carl
Kirix Support Forums
Convert Hex to decimal (for IP address)
3 posts
• Page 1 of 1
- cjbaccus
- Registered User
- Posts: 4
- Joined: Thu May 21, 2009 9:21 am
Re: Convert Hex to decimal (for IP address)
I had a little fun and coded it for you
- Code: Select all
function convertHexToDecIP(str)
{
var i, ret = '', parts = str.split(" ");
for (i = 0; i < parts.length; ++i)
{
if (i > 0)
ret += '.';
ret += parseInt(parts[i], 16);
}
return ret;
}
print(convertHexToDecIP("C0 A8 01 01"));
Ben Williams
Kirix Support Team
Kirix Support Team
-
Ben - Kirix Support Team
- Posts: 525
- Joined: Mon Dec 19, 2005 6:29 am
Re: Convert Hex to decimal (for IP address)
YOU ROCK BEN!!!!
Thank You Very Very much! That has given me ideas on how to do several other functions too!!
Thank You Very Very much! That has given me ideas on how to do several other functions too!!
- cjbaccus
- Registered User
- Posts: 4
- Joined: Thu May 21, 2009 9:21 am
3 posts
· Page 1 of 1
Return to Strata Help & Feedback