Go Back   The macosxhints Forums > OS X Help Requests > UNIX - General



 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
Old 07-04-2008, 04:09 AM   #1
aslam
Prospect
 
Join Date: Feb 2007
Location: Vancouver, Canada
Posts: 4
Terminal Command to obtain Local Computer Name (.local)

Does anyone know of a terminal command or Java method/global parameter to determine the local computer name (e.g. my-macbook.local) of an OS X machine?

I need to identify a machine reliably on a regular basis. Thus far we have been using the "hostname" command and that worked fine at first. However we recently realized that this is usually automatically populated by the ISP (via DHCP) with a DNS name (e.g.: xxx-xxx-xxx-xxx.example.com). Now, this works fine for home users because their ISP assigned hostname rarely changes. However with travelling/laptop users this can be a real problem because when they go to another ISP (hotel, airport, client site) their computer gets a new hostname from the local ISP. This breaks our code which is looking for the hostname that the computer had before.

Therefore we need to find an alternative way to reliable identify the same computer, time and time again. I recently realized that there is an OS X machine name which is set in System Preferences -> Sharing -> Edit. It typically looks something like "my-macbook.local". So I thought if I can find out the terminal command to report that, I can suggest our programmers use that variable.

Failing that, does anyone know of a reliable way to identify the same computer, time and time again no matter what internet connection it is on?

Thanks,
Aslam
aslam is offline   Reply With Quote
 

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 03:02 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Site design © Mac Publishing LLC; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of Mac Publishing LLC.