Skip to content

Instantly share code, notes, and snippets.

@wvanbergen
Created November 16, 2011 05:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wvanbergen/1369328 to your computer and use it in GitHub Desktop.
Save wvanbergen/1369328 to your computer and use it in GitHub Desktop.
Get the computer and display serial numbers for your Mac
require 'yaml'
data = YAML.load(`system_profiler SPHardwareDataType SPDisplaysDataType`)
puts "Computer serial number: " + data['Hardware']['Hardware Overview']['Serial Number (system)']
data['Graphics/Displays'].each do |video_card, properties|
if properties['Displays']
properties['Displays'].each do |display_name, properties|
puts "#{display_name}: #{properties['Display Serial Number']}" if display_name =~ /Cinema/
end
end
end
@wvanbergen
Copy link
Author

Next step: webapp to submit this information to :)

@tobi
Copy link

tobi commented Nov 16, 2011

Let's add that as fields to unicorn!

@wvanbergen
Copy link
Author

To run:

curl -s https://raw.github.com/gist/1369328/inventory_serials.rb | /usr/bin/env ruby

@reggi
Copy link

reggi commented Dec 1, 2014

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment