I've been trying to figure out something that is probably very simple but it's taking much longer than I thought so I thought I'd ask here. I want to be able to set the hostname of many computers to match the "Computer Name" that the finder displays in the sharing Preference Pane. I need a command I can push out to a few hundred computers over the network using Remote Desktop.
The command to get the Computer name is
Code:
/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/systemsetup -getcomputername
which produces the following output...
Code:
Computer Name: Laurence Hawkins
I then need to feed that output minus the "Computer Name: " into the "hostname" command to set the UNIX hostname to match. The problem is that I don't know how to remove the "Computer Name: " and replace the spaces in the name with underscores which seems to be necessary for this to function correctly.
If anyone has a simpler way to do this I would also appreciate any ideas! Really I just don't want to have to rename all these machines manually! The computer names are all correct, but for some reason many of the hostnames are hopelessly out of date and mention employee names that no longer work here!
Thanks!
edit: Fixed "code" tags. -[APi]TheMan