in reply to Can Perl read the hard drive registration #?

Try being more specific. What operating system, what do you mean by "registration numbers"?

For example, you can query a drive on capabilities and vendor strings under Linux with the hdparm command:

# hdparm -i /dev/hda /dev/hda: Model=WDC WD307AA-00BAA0, FwRev=10.09K11, SerialNo=WD-WMA2F2556865 Config={ HardSect NotMFM HdSw>15uSec SpinMotCtl Fixed DTR>5Mbs FmtGap +Req } RawCHS=16383/16/63, TrkSize=57600, SectSize=600, ECCbytes=40 BuffType=DualPortCache, BuffSize=2048kB, MaxMultSect=16, MultSect=1 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=60074784 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120} PIO modes: pio0 pio1 pio2 pio3 pio4 DMA modes: mdma0 mdma1 mdma2 udma0 udma1 *udma2 udma3 udma4 AdvancedPM=no WriteCache=enabled Drive Supports : Reserved : ATA-1 ATA-2 ATA-3 ATA-4

And if the serial number is what you're looking for, here's a Perl script to extract it:

#!/usr/bin/perl my $query = qx{hdparm -i /dev/hda} or die $!; print "HDD serial number is: $1\n" if $query =~ m/SerialNo=([^,\s]+)/s;

The output on my system is:

HDD serial number is: WD-WMA2F2556865

Replies are listed 'Best First'.
Re: Re: Can Perl read the hard drive registration #?
by Anonymous Monk on Mar 20, 2004 at 17:20 UTC
    I am on Windows XP but I plan on running this on my server to people can run it web-based if possible? Or will it search my server rather than their hard drive?

    I get an error while running your script though "'hdparam' is not recognized as an internal or external command...".

    Thanks.

      It'll show them the info about your servers Hard drive... And as far as I know, there's no way to show their hard drives info... But, just in case you want it for some other reason, try the vol command in WinXP. atm, I don't have time to work out a script to just get the serial number. But, the output is as follows (on my machine at least):

      Volume in drive C has no label. Volume Serial Number is 7C9B-238A
      Just Another Perl Alchemist

      hdparm is a Linux-only command, as I said in the original reply. Also you need root privileges to run it.

      As of Windows XP, you're out of luck with me... ;)