February 10, 2016

Getting Your IP Address

As an engineer, you may need to know what your current IP address is. You may need this for various config settings or to let the IT team know.

So, why not spend a few minutes today and set up a couple of TextExpander snippets so that you can easily get your IP address whenever you need it. It's pretty easy to setup.

External IP Address

This will show you the external IP address that the world sees. Thanks for applewriter.com for the fundamentals of getting the data.

Applescript External IP

Sample Code:

(*
Credit to www.applehelpwriter.com
*)
set myTemp to do shell script "mktemp -t txt"
do shell script "curl -s http://checkip.dyndns.org &> " & myTemp & " &2> /dev/null"
# CHANGE THE DELAY HERE...             
delay 3
set extIP to do shell script "sed 's/[a-zA-Z/<> :]//g' " & myTemp

Internal IP Address

This is you Internal IP that could be automatically generated from you internal router. Some machines might be configured to always use the same IP address.

Internal I P

Sample Code:

set tIP to do shell script "ifconfig en0|grep 'inet '|cut -d ' ' -f 2"

Comments

Add your Comments

Feel free to leave a comment about this post.

- Feel Free to add HTML to your comment!