Getting Mac serial number

May 17, 2011 at 8:10am

Getting Mac serial number

I am writing licensing code and am trying to find a way to get the unique mac serial out of the shell object. Only thing is, shell doesn’t accept lines like this:

ioreg -l | awk ‘/IOPlatformSerialNumber/ { split($0, line, “”"); printf(“%sn”, line[4]); }’

I understand something can be done with sprintf, but I have no knowledge of scripting.

Anyone have any tips?

May 17, 2011 at 9:20am

send this to shell works for me:
ioreg -l | grep IOPlatformSerialNumber

print: ” | “IOPlatformSerialNumber” = “***********”"

regexp this answer and it’s done

May 17, 2011 at 9:54am

Thanks, that’s more than I got in the first place!

I’m not getting the hang of regexp. How can you use it to strip the number from this string?

May 17, 2011 at 10:02am

Does the serial always start with a W?

May 17, 2011 at 12:45pm



– Pasted Max Patch, click to expand. –



You must be logged in to reply to this topic.