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?

#57170
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

#204810
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?

#204811
May 17, 2011 at 10:02am

Does the serial always start with a W?

#204812
May 17, 2011 at 12:45pm

here’s:

`

– Pasted Max Patch, click to expand. –

ad

#204813

You must be logged in to reply to this topic.