Title: Message
I don't think you need the backslash at the end.  Here is the code I was using, and it works okay from here:

use Win32::Lanman;
use
Win32::Adminmisc;
use
strict;
use
warnings;

my $client = "c014193a"
;
my @driveinfo
;

getDDInfo(
$client,\@driveinfo) || die
;

foreach(@driveinfo
){
    print join("\t"
,($_->{name},$_->{capacity},$_->{space},$_->{percent}."\%"))."\n";
}


sub
getDDInfo{
    my $client = $_
[0];
    my @drives;
    Win32::Lanman::NetServerDiskEnum(
"\\\\$client"
,\@drives) || return 0;
    foreach my $drive(@drives
){
        $drive =~ s/\://
g;
        @drvinfo = Win32::AdminMisc::GetDriveSpace("\\\\$client\\$drive\$"
) or next;
        my $capacity = sprintf("%5.2f"
,($drvinfo[0]/1073741824)); #Convert to GigaBytes
        my $space = sprintf("%5.2f"
,($drvinfo[1]/1073741824));
        my $percent
;
        $space =~ s/\s//
;
        $capacity =~ s/\s//
;
        unless($capacity < .
01){
            $percent = sprintf("%.02f"
,$space / $capacity * 100);
        }
        push @{$_[1]},{name => $drive, capacity => $capacity, space => $space, percent => $percent
};
    }
    return 1;
}


 

-----Original Message-----
From: Rob Dowell [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 15, 2003 3:18 PM
To: win32-admin
Subject: RE: getting remote hard drive space

I recommend using WMI for this (if you are in a windoze environment). There is a perl interface for it or you could interface through jscript, vbscript, or .Net.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Sumit
Sent: Wednesday, October 15, 2003 4:46 PM
To: win32-admin
Subject: getting remote hard drive space

Hi All,
I am using the Win32::AdminMisc module to build some inventory information within our network. I am trying
the GetDriveSpace function to get the size of remote hard drives. The documentation of the module says that
if a UNC is used instead of local drive then a backslash should be used at the end. Here is what I am using
 
$drive = "\\\\$server\\C\$\\";
{($FixedDrives{$drive}->{Size}, $FixedDrives{$drive}->{Free}) = Win32::AdminMisc::GetDriveSpace($drive);}
 
And on running this I get undefined value. Any idea whats wrong with the code or has anyone encountered this
before. I got the module from Jenda Krynick's ppm repository.
 
Also is there any way to find out the number of fixed drives on a remote machine?
 
Thanks in advance,
Sumit.
 

Reply via email to