Getting the IP address from a URL

Okay, let’s see if I can put this in a way that makes sense…

What I need: The IP address of a remote machine that I only have the URL for (

Why I need it: I have three locations. Site “A” hosts the Web server, FTP server, SMTP server, and the necessary databases. Site “B” and site “C” need to access the databases via applescripts (“eppc://” & user & “:” & password & “@” & IPAddress & “:3031”). My provider assigns me a DHCP address so it COULD change at any time and while I have a registered URL through that does me no good as far as the remote scripting is concerned since the ‘eppc://’ syntax requires an IP address and not a URL as far as I know.

I know that running a trace route will give me a line like this at the beginning:

but I don’t need to run a trace route, I only want the for my remote Macs to use as a variable. Does anyone know how to go about getting the IP address from a remote machine using an URL?

It looks like that should work: Remote Applications

I stumbled across a page which mentioned “lookup” as a way to get an IP address from a URL but since I don’t think lookup is an applescript command I looked for a unix alternative (WARNING - I am hopeless when it comes to unix!!!)

The command seems to be:

So I am guessing the script I need to write will be something like:

do shell script (nslookup
-- then I need to use applescript to parse the result to get at the IP

I will test this when I get back home to my Mac, but I strongly suspect this wont work. Like I said - my unix skills are for shite!

Well it actually turned out to be:

set lRemoteIP to do shell script "nslookup"

if lRemoteIP ≠ "" then
	set lRemoteDataList to every word of lRemoteIP as list
	set lDesiredIP to item -1 of lRemoteDataList
end if

return lDesiredIP

but being able to use

set lRemoteMac to "eppc://"

is just SO much better! :cool: (though I will store mine away just in case).

Thanks Bruce.

Nothing I read EVER mentioned being able to use a URL so I didn’t even try it. I knew about using the computername.local but only for the local network. Thank you SO MUCH for saving me from a unix headache!

This script by Kai Edwards returns an IP address for an entered URL:

text returned of (display dialog "Enter a URL in the text box below:" default answer ¬
	"[url=][/url]" buttons {"OK"} default button 1) as string returning {text:theURL}
-- the following line presumes that a reasonable URL has been entered in the form given by the default - it will not correct anything else.
if theURL does not contain "http://" then set theURL to "http://" & theURL
	set theHost to (dotted decimal form of ((theURL as URL))'s host)
	display dialog (theURL & "'s IP Address is: " & theHost) buttons {"OK"} default button 1
on error
	display dialog "No such URL" buttons {"Too Bad"} default button 1
end try