Dear Scripters,
I am a neophyte and would greatly appreciate some expertise in de-bugging a short script. I am trying to get the Hardward UUID (machine unique indentifier) which is under the Hardware Overview in the application System Profiler in OSX 10.5.8. I spent a day with the script and believe I am close with the following three attempts.
First Attempt:
tell application
“Systemprofiler”
return ((value of Hardwareuuid) / hardwareoverview)
end tell
Second attempt:
tell application
“Systemprofiler”
return ({value of Hardwareuuid} / hardwareoverview) / (machine macintoshHD)
end tell
Third Attempt:
tell application
“Systemprofiler”
get ((serialnumber of “Hardwareuuid”) / “hardwareoverview” /
“macintoshHD” / (“DANPEPPER’s macmini”))
end tell
I want to use this script in a FMP program to assign a specific copy of the software to a specific machine. If someone could tell me what I am doing wrong it would be greatly appreciated.
Basically, you’re just guessing and hoping the answer will come out.
System Profiler produces a text report which you have to parse for the information you require:
tell application "System Profiler"
set p to system profile
quit
end tell
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "Hardware UUID: "
set uuid to paragraph 1 of text item 2 of p
set AppleScript's text item delimiters to astid
uuid
There’s also a shell script equivalent (as ief2 has pointed out) which saves having to open the System Profiler app and can also be tailored to narrow down the data search so that it executes faster:
do shell script "system_profiler SPHardwareDataType | grep 'Hardware UUID:'"
set uuid to text ((offset of ":" in result) + 2) thru -1 of result
Thanks ief2 and NG, all versions worked great. I now see NG you were right, I wasn’t even close and ief2 is amazing considering he is only 14 years old. You have a big head start dude, should be a bright future ahead.