Reputation: 3
I am very new to the mac and have No idea how to do this. Basically I'm working on a remote VNC script and the app itself works great and my script that loads it also works but I cannot get it to resolve names to ip's..
So Id like to script in something with applescript to do just that before it loads the VNC app and shoves the current IP into the command it gives to the shell.
Currently the script is this
do shell script "'/Vine Server.app/OSXvnc-server' -connectHost myhost.dyndns.org -connectPort 5905"
If I plug in a IP address inplace of the host, it works. but it will not resolve so hopefully someone can tell me how to make Applescript do just that.
incase I have confused, heres exactly what I'm looking for.
do shell script "'/Volumes/Remote Connection/Vine Server.app/OSXvnc-server' -connectHost "Applescript insert IP" -connectPort 6000"
Thank your for your help.
Upvotes: 0
Views: 328
Reputation: 19030
There's a command line utility "host" that will do this for you. I made a little handler ipForHostName() to run the host command and parse the text to return only the ip address...
set hostName to "myhost.dyndns.org"
set ipAddress to ipForHostName(hostName)
do shell script "'/Vine Server.app/OSXvnc-server' -connectHost " & quoted form of ipAddress & " -connectPort 5905"
on ipForHostName(hostName)
try
do shell script "/usr/bin/host " & quoted form of hostName & " | grep \"has address\""
return last word of result
on error
return hostName
end try
end ipForHostName
Upvotes: 1