tlemons has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I need to perform SCSI operations (notably inquiry and some reading) on SCSI devices from Perl. I thought I was in hog heaven when I found Peter Corlett's Device::SCSI module; it seems to do exactly what I need. Alas, Device::SCSI only supports Linux at this time.

Any other thoughts?

Thanks! tl

Replies are listed 'Best First'.
Re: SCSI operations in Perl
by ikegami (Patriarch) on Apr 21, 2005 at 19:16 UTC

    This works for CD-ROMs.

    use Win32::OLE (); my $computer = '.'; my $obj = Win32::OLE->GetObject("winmgmts:\\\\$computer\\root\\cimv2") or die("$^E\n"); my $devices = $obj->ExecQuery(" SELECT * FROM Win32_CDROMDrive "); foreach my $device (Win32::OLE::in $devices) { print $device->{ DeviceID }, $/, $device->{ Description }, $/, $device->{ Name }, $/; }

    Maybe this works for SCSI devices? (I don't have any to use for testing.)

    use Win32::OLE (); my $computer = '.'; my $obj = Win32::OLE->GetObject("winmgmts:\\\\$computer\\root\\cimv2") or die("$^E\n"); my $devices = $obj->ExecQuery(" SELECT * FROM Win32_SCSIControllerDevice "); foreach my $device (Win32::OLE::in $devices) { my $dependant = $device->{Dependent}; print $dependant->{ DeviceID }, $/, $dependant->{ Description }, $/, $dependant->{ Name }, $/; }

    References:
    The Win32_CDROMDrive class ($device in first snippet)
    The Win32_SCSIControllerDevice class ($device in second snippet)
    The Win32_SCSIController class (might be of interest)
    The CIM_LogicalDevice class ($dependant)

    I hope this gives you a starting point.

Re: SCSI operations in Perl
by Fletch (Bishop) on Apr 21, 2005 at 17:20 UTC

    Well, you've helpfully narrowed things down by stating one of the OSen you're not using. Everyone fire up PSI::ESP and guess what he is using . . .

      Sounds like a queston from a WinXP user ;-)

      According to http://www.cabal.org.uk/freeware/perl/Device::SCSI.html

      The module is modular (oddly enough), and it would be reasonably simple to extend to support SCSI access on other platforms.
      So just hack around with the code.

      When I come across stuff like this, I realize I'm just a wannabe geek.

        Yes, I do need to make this work on Windows (2003 and 2000, specifically). I'm not easily capable of extending Device::SCSI; otherwise, I'd gladly extend the prior work.

        But, if I do have to try to extend Device::SCSI, do you have any helpful suggestions? For instance, the Linux implementation looks for instances of /dev/sg??; this same technique will not work on Windows (I think). So, what would work, that could be used programatically from Perl?

        Thanks tl