Script to get computer name

I’ve been looking for some examples of how to get a computer’s name and verify that it is NOT the default name we use in our cloning process. We use ARD fields 1-4. F1 is coomputer name, F2 is ser#, F3 is user’s first and last naem and F4 is the users phone extension. I’ve seem some examples out there, but not quite what I’m looking for.
We are using 10.3 client.

I’d like to check the computer name.
Verify it’s not or “”
Pop up a message if it needs to be configured.

Thanks for your help,

Here’s a few ways, each new line is a separate script…

[This script was automatically tagged for color coded syntax by Script to Markup Code]

I appreciate the input.
I did some tests with these commands and they do not seem to effect change on the sharing prefs/computer name OR sharing/ARD/fields 1-4.
Any other suggestions?

I have been trying to use something like this in a AS command:

system_profiler | grep "Computer Name:"

and then do some checks from there with shell commands, etc.

You can run
"env | grep ‘HOST=’ "
which will produce
“HOST=<computer_name>.local”

I am really not trying to be difficault here, but none of the suggestions so far seems to reflect the computer’s real name and the Apple Remote Desktop Fields 1-4.

If this was the OS X server I could just use systemsetup and network setup to do all this, but those tools are not available on the client.

Is this what you mean?

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Before respnding to this request please verify you are using OS 10.3 lcient and Apple Remote Desktop (built in). Go to the System Prefs/Sharin g and click on access privileges. A new window will appear with the settings for Information Fields 1 thru 4. These are the fields that I want to verify, check and possibly change via a script.

I already had some great responses to the general computer name issue.

thanks,

Here:

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

An FYI just to clearify things – ARD is not ‘built in’ to Mac OS 10.3.1, as your post seems to indicate. Apple Remote Desktop is a $299.00 shareware program that you can buy from Apple Comp. Inc.

The ARD is built in to 10.3.
If you need to manage workstations you would need to buy the admin software.

source – http://www.apple.com/remotedesktop/

I am running Mac OS X 10.3.1 (Client, not Server) and a search for ‘Apple Remote Client’ comes up empty on my machine. Your posts seem to indicate that ARD client is instaled on my machine, whereas as Apple says it can be installed on up to 10 or more machines depending upon which license you own. I do not own ARD, but if the client is installed I would certainly like to know about it. Do tell ;¬)

Greg, try going to System Preferences > Sharing. Then from the Services tab, select Apple Remote Desktop. It is the server software for which Apple charges.

Jon

PS Apple touts that the client is included in 10.3 on this page: [url=http://www.apple.com/macosx/newfeatures/systemadministrators.html]http://www.apple.com/macosx/newfeatures/systemadministrators.html[/url]

Thanks all, I stand corrected…

BTW, as we were speaking of ARD, there is a new update for it – check your Software Update control panel.

This was very confusing because you kept referring to the computer name. The fields in the ARD setup are not designated as computer name or anything else, they are completely arbitrary. That said, did the last code I posted above finally work for you?

Jon

I downloaded a script and modified it for Panther 10.3 This is the script I use after I image a machine

set Profile to do shell script “/usr/sbin/system_profiler SPHardwareDataType”
set SN_Start to ((offset of “Serial Number” in Profile) + 15)
set Partial to text SN_Start thru (length of Profile) of Profile
set SN_End to offset of " " in Partial
set SN to text 1 thru SN_End of Partial

set result to display dialog “What is the name of this computer?” default answer “”
set TheName to text returned of result

set result to display dialog “What is the Tag# of this computer?” default answer “”
set TheTag to text returned of result

tell application “System Preferences” to activate
tell application “System Events”
get properties
tell application process “System Preferences”
click button “Sharing” of scroll area 1 of window “System Preferences”
delay 3
click button “Edit…” of window “Sharing”
set value of text field 1 of sheet 1 of window “Sharing” to TheName
click button “OK” of sheet 1 of window “Sharing”
keystroke tab
keystroke tab
delay 3
tell application “System Events”
repeat 5 times
keystroke (ASCII character 31)
end repeat
end tell
click button “Access Privileges…” of tab group 1 of window “Sharing”
delay 3
set value of text field 1 of group 2 of sheet 1 of window “Sharing” to TheName
set value of text field 2 of group 2 of sheet 1 of window “Sharing” to TheTag
set value of text field 1 of group 1 of sheet 1 of window “Sharing” to SN
click button “OK” of sheet 1 of window “Sharing”
keystroke tab – forward tab key
end tell
end tell