Machine network names
J. Landman Gay
jacque at hyperactivesw.com
Wed Oct 5 23:54:18 EDT 2005
Devin Asay wrote:
> Jacque,
>
> I'm tardy here, but didn't see any replies.
>
> Could you write a shell script that ssh'ed to the remote machine,
> then check the $HOST variable. Kinda roundabout, I know.
>
> Or how about just getting the number of bytes of data on each disk.
> Not guaranteed to be unique, but the chances of duplicated numbers
> would be miniscule.
And Andre Garzia also wrote:
> Is this program running on remote machine or local machine wondering
> about a remote connection?
>
> Some way to do this is by using reverse dns lookup. you can use "host
> <ip address>" on a shell command to resolve it back to the hostname
> but this works only with registered ips. From your email I thing
> you're mounting remote volumes (which might have the same name) and
> trying to give each of them their own unique ID. Well why not
> pregenerate tons of unique IDs and assigning them as temporary files
> on the remote volumes, this way you could just query /RemoteVolume/
> myUniqueID.txt and see who is who... don't know, this feels like a
> hack. What are you trying to do and what information you have on the
> remote machines?
You guys are too geeky. :) I figured out way to do it, I think.
What I'm doing: I need to create an encrypted ID that is tied to a
particular machine, for licensing purposes, which is why I need a
machine-unique identifier. However, the program also needs to run from a
server. So, I need to get the identity of the host machine so that I can
calculate a correct ID.
After some googling, I found that all the machine-specific info on an OS
X installation is stored in this file:
/Library/Preferences/SystemConfiguration/preferences.plist
The file exists on all versions of OS X I have checked, back to at least
early Jaguar. It has "read" privileges for everyone. Once I discovered
that, it was a simple matter to write a handler that just opens the file
on the server, reads it, and parses out the machine info. No shell
commands or anything else necessary, just plain Transcript.
What I eventually decided to use for the unique machine ID -- instead of
its network name -- was the host machine's MAC address. This handler
gets that info, regardless of whether the program is running locally or
remotely:
function getmachineID
-- get the host's MAC address whether running locally or from server:
put the address into tAddr
set the itemDel to slash
if tAddr contains "Volumes/" and CDPath() is not in tAddr then --
assume running on server
put "/" & item 2 to 3 of tAddr into tConfigPath
else -- local copy, or from CD
put empty into tConfigPath
end if
put "/Library/Preferences/SystemConfiguration/preferences.plist"
after tConfigPath
put "" into tMacAddr
if there is a file tConfigPath then
put url ("file:"&tConfigPath) into tConfig
put line lineoffset("MACAddress",tConfig)+1 of tConfig into tMacAddr
delete char 1 to offset(">",tMacAddr) of tMacAddr
delete char offset("<",tMacAddr) to -1 of tMacAddr
end if
return tMacAddr -- empty if failed
end getmachineID
The CDPath() function just returns a string consisting of the path to
the install CD (just in case it is in the drive.) This handler seems to
work so far, but if anyone notices any snafus I haven't considered, it
would be good to know.
>
> On Oct 3, 2005, at 5:00 PM, J. Landman Gay wrote:
>
>> I want to know the network name of a remote machine on a network.
>> For a local machine, I can get "the address" and the first part of
>> the address is the name I'm looking for. But on a remote, mounted
>> volume "the address" doesn't include its machine name. Any ideas? I
>> only need this for Mac OS X, but it has to work for all but the
>> earliest versions of OS X.
>>
>> If I can't easily get the network name, then any unique identifying
>> info would do. I considered getting the machine ID using Ken Ray's
>> "stsGetSerialNumber" handler, but it only returns the serial
>> numbers of local hard drives.
>>
>> The only requirements are: it has to be a unique identifier, and it
>> has to be obtainable both remotely and locally.
>>
>> -- Jacqueline Landman Gay | jacque at hyperactivesw.com
>> HyperActive Software | http://www.hyperactivesw.com
>> _______________________________________________ use-revolution
>> mailing list use-revolution at lists.runrev.com Please visit this url
>> to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode
mailing list