Figuring out the chassis serial numbers of a machine from within a script

February


On some machines, this works beautifully:

sudo apt-get install dmidecode
sudo dmidecode
# dmidecode 2.9
SMBIOS 2.5 present.
69 structures occupying 2027 bytes.
Table at 0x000EA7C0.

Handle 0x0001, DMI type 0, 24 bytes
BIOS Information
Vendor: Hewlett-Packard
Version: 786F2 v01.04
Release Date: 01/31/2008
Address: 0xE0000
Runtime Size: 128 kB
ROM Size: 4096 kB
Characteristics:
        PCI is supported
        PNP is supported
        BIOS is upgradeable
        BIOS shadowing is allowed
        Boot from CD is supported
        Selectable boot is supported
        EDD is supported
        Japanese floppy for Toshiba 1.2 MB is supported (int 13h)
        3.5"/720 KB floppy services are supported (int 13h)
        Print screen service is supported (int 5h)
        8042 keyboard services are supported (int 9h)
        Serial services are supported (int 14h)
        Printer services are supported (int 17h)
        ACPI is supported
        USB legacy is supported
        LS-120 boot is supported
        ATAPI Zip drive boot is supported
        BIOS boot specification is supported
        Function key-initiated network boot is supported
        Targeted content distribution is supported
BIOS Revision: 1.4

Handle 0x0002, DMI type 1, 27 bytes
System Information
Manufacturer: Hewlett-Packard
Product Name: HP Compaq dc5800 Small Form Factor
Version:
Serial Number: CZC90150YX
UUID: AF9DC2C8-EDDD-DD11-BBDA-7D1BF7C10023
Wake-up Type: Power Switch
SKU Number: AJ411AV
Family: 103C_53307F

Handle 0x0003, DMI type 2, 14 bytes
Base Board Information
<snip>

[Note]Note

On other machines though, most of the information is blank, or nonsense