NSLookup

I’d like to give my scripts the ability to look up the ip address of a URL, and vice-versa. Can anyone suggest a (freeware?) osax or scriptable utility that might do the job? I’ve searched here and the web, and all I’ve found so far is the scriptable application NSLookup (http://www.baylor.edu/~Carl_Bell/ReadMeFiles/NSLookup.html), which would have been perfect had it not been a Classic application.

Thanks!

Thanks! That’s just what I was looking for. I didn’t even know AppleScript could execute commands in the shell.

Yes, I’d much prefer an OS X solution. Sorry, could have made that more clear :slight_smile:

set theResult to do shell script "NSlookup domainname"
display dialog theResult

So when you say “had it not been a Classic application”, does this mean that you want an OS X solution?

for Standard Additions you can invoke any shell script by the command:

do shell script

pretty fancy huh

also look at system events :wink:

cheers

do shell script: execute a shell script or command
	do shell script  plain text  -- the command or shell script to execute.  Examples are ‘ls’ or ‘/bin/ps -auxwww’
		[administrator privileges  boolean]  -- execute the command as the administrator
		[password  plain text]  -- use this administrator password to avoid a password dialog
		[altering line endings  boolean]  -- change all line endings to Mac-style and trim a trailing one (default true)
	[Result:   plain text]  -- the command output

Class POSIX file: A file object specified with a POSIX (slash)-style pathname.
Properties:
	POSIX path  'file'  [r/o]  -- the POSIX (slash)-style path of any file or alias object

You could have always used the built-in commands of standard additions.
Like so…

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

local adomain, aURL
set adomain to "apple.com"
set aURL to ("http://" & adomain) as URL
dotted decimal form of host of aURL

Or…

use scripting additions

set aurl to "https://google.com" as URL
get dotted decimal form of host of aurl

Or…

set aurl to "https://google.com" as URL
tell aurl to set ipAddr to dotted decimal form of its host

Or even…

do shell script "dig google.com +short"