How I could aquire the customer serial number?

Hello everybody!
Searching throught the archives I found, thanks to Jonathan Nathan, that a serial number can be aquired with the command line:
ioreg -l | grep serial-number | awk '{print $2, $4}
Does anybody know how I could aquire the customer serial number, the one that is displayed on the apple system profiler screen? I am working on MacOS X 10.2.8.
It doesn’t necessarily have to be a command line. An applescript method, if any, of aquiring that information woud also be welcome!
Any help will be much appreciated!
Thanks,
Theo

Actually, it was Greg who came up with the SN info. On my machine, this returns an encoded string that needs to be converted (and then tweaked one last bit):

set the_sn to text 2 thru -2 of (do shell script "ioreg -l | grep serial-number | awk '{print $4}'")
set the_sn to hex_to_string(the_sn)
--on my machine, this is close but needs a slight reworking:
set the_sn to ((text 4 thru -1 of the_sn) & (text 1 thru 3 of the_sn))

on hex_to_string(this_string)
	set return_string to ""
	repeat with i from 1 to length of this_string by 252
		try
			set return_string to return_string & (run script "?data cstr" & (text i thru (i + 251) of this_string) & "00? as string")
		on error
			set return_string to return_string & (run script "?data cstr" & text i thru -1 of this_string & "00? as string")
		end try
	end repeat
	return return_string
end hex_to_string

Jon

Thank you Jon! You are a savior!
Apologies for the late reply but I was caught up on cruise ship project working on location.
Your solution is great! The only problem I am having with the script is that somehow what it appears as an “-” (dash) on the system profiler translates as an “H” when I use the script. Any ideas why this is happening?
A have a few more questions:

  • An applescript running on the same eMac under MacOS 9.2 reads 4 extra digits when it is aquiring the serial number info. Any ideas why I am not getting a report of those on MacOS 10.2.8 how to finally aquire those numbers as well?
  • Any pointers to get more info on the
"«data cstr" 

part of your script?

  • Any pointers to a list with all the related call statements using the ioreg method on a shell script?
    Once again thank you!

Theo