• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Need to translate IP addresses from hex value to dotted quad?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Need to translate IP addresses from hex value to dotted quad?


  • Subject: Need to translate IP addresses from hex value to dotted quad?
  • From: Michelle Steiner <email@hidden>
  • Date: Tue, 13 Mar 2001 17:01:45 -0800

Here's a script that will do just that.

--Michelle

set testHexIP to "D867DB2D"
set decimalIP to ""
repeat with i from 1 to 4
set theitem to text (i * 2 - 1) through (i * 2) of testHexIP
log theitem
set sum to 0
repeat with j from 2 to 1 by -1
set val to (offset of (character j of theitem) in "123456789ABCDEF")
set sum to sum + val * (16 ^ -(j - 2))
end repeat
set decimalIP to decimalIP & sum & "."
end repeat
set decimalIP to text 1 through -1 of decimalIP
-->"216.103.219.45."

Note: the hex alpha characters must be in upper case for this script to
work.

----------------------------------------------------------------------
| Michelle Steiner | We're not human beings having a spiritual |
| | experience. We're spiritual beings |
| email@hidden | having a human experience. |
----------------------------------------------------------------------


  • Prev by Date: Re: upgrade issues: 8.1 --> X
  • Next by Date: RE: Mounting volumes
  • Previous by thread: Making AppleScript URL handlers (WAS: Web browser new-window opener)
  • Next by thread: Re: I reserve the right to pronounce "X" as "Ex"
  • Index(es):
    • Date
    • Thread