• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: One for the experts: Serial Number of computer using Applescript Studio
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: One for the experts: Serial Number of computer using Applescript Studio


  • Subject: Re: One for the experts: Serial Number of computer using Applescript Studio
  • From: Hudson Barton <email@hidden>
  • Date: Fri, 17 Jun 2005 15:57:24 -0400

set sn to (do shell script "system_profiler SPHardwareDataType | grep Serial")
text ((offset of "Serial Number:" in sn) + 15) thru (length of sn) of sn

--result (for you) in 10.4.1 should be "QP510016PNZ"


-- or do this

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 - 2) of Partial

H.

At 12:03 PM -0700 6/17/05, Gabe Lucero wrote:
All of the sn retrieval suggestions worked in Tiger 10.4.1 just fine. However, how could I pull the serial number without the result being-

"Serial Number: QP510016PNZ"

But rather just the sn so I can paste it into the Remote Desktop computer info fields? Such as-

"QP510016PNZ"

I used the following script to do this in 10.3 but it won't work in 10.4 for some reason.

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


These are the two scripts I've found will work in 10.4 but gives me the whole sn line:


do shell script "system_profiler SPHardwareDataType | grep Serial"


And


tell application "System Profiler" set SN to "" set sp to system profile repeat with p in paragraphs of sp if p contains "Serial Number:" then set SN to contents of p exit repeat end if end repeat SN end tell

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: One for the experts: Serial Number of computer using Applescript Studio (From: Gabe Lucero <email@hidden>)

  • Prev by Date: CURL vs FTP
  • Next by Date: Re: CURL vs FTP
  • Previous by thread: Re: CURL vs FTP
  • Next by thread: Re: One for the experts: Serial Number of computer using Applescript Studio
  • Index(es):
    • Date
    • Thread