Skip to content

Instantly share code, notes, and snippets.

@msabramo
Created September 30, 2017 16:01
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 msabramo/04fb8022e570a418640b8033ecb13e30 to your computer and use it in GitHub Desktop.
Save msabramo/04fb8022e570a418640b8033ecb13e30 to your computer and use it in GitHub Desktop.
Script to get the serial number of a Mac OS computer
#!/usr/bin/expect -f
#
# Script to get the serial number of a Mac
#
set timeout 10
log_user 0
spawn /bin/sh -c "ioreg -rac IOPlatformExpertDevice | xpath 'plist/array/dict/key\[.=\"IOPlatformSerialNumber\"\]/following-sibling::*\[position()=1\]/text()' 2>/dev/null"
expect eof
set serial $expect_out(buffer)
puts $serial
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment