Sunday, November 19, 2017

#1 2009-04-02 12:21:01 am

cirno
Member
Registered: 2005-05-30
Posts: 448

Model Identifier

I'm looking for a way to get Model Identifier. (iMac7,1)

Offline

 

#2 2009-04-02 01:48:31 am

Martin Michel
Administrator
From:: Berlin, Germany
Registered: 2008-03-03
Posts: 701
Website

Re: Model Identifier

How about this piece of code?

Applescript:


set macmodel to my getmacmodel()

on getmacmodel()
   set macmodel to missing value
   set command to "system_profiler SPHardwareDataType"
   set paras to paragraphs of (do shell script command)
   repeat with para in paras
       if para contains "Machine Model:" then
           set colonoffset to offset of ":" in para
           set macmodel to (characters (colonoffset + 2) through -1 of para) as text
           exit repeat
       end if
   end repeat
   return macmodel
end getmacmodel


Plonum - Convert images to iWork Numbers documents

Offline

 

#3 2009-04-02 02:05:13 am

cirno
Member
Registered: 2005-05-30
Posts: 448

Re: Model Identifier

Thanks, it works if i change "Machine Model" to "Model Identifier".

Applescript:

set macmodel to my getmacmodel()

on getmacmodel()
   set macmodel to missing value
   set command to "system_profiler SPHardwareDataType"
   set paras to paragraphs of (do shell script command)
   repeat with para in paras
       if para contains "Model Identifier:" then
           set colonoffset to offset of ":" in para
           set macmodel to (characters (colonoffset + 2) through -1 of para) as text
           exit repeat
       end if
   end repeat
   return macmodel
end getmacmodel

Offline

 

#4 2009-04-02 02:57:47 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11482
Website

Re: Model Identifier

…or

Applescript:


set macmodel to do shell script "/usr/sbin/system_profiler SPHardwareDataType | /usr/bin/awk '/Model Identifier/ {print $NF}'"


regards

Stefan

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)