in reply to Trying to get drive space info on remote Windows servers

but only returns zero for remote servers.

If the total bytes count is zero, it probably means that the call is failing--perhaps the userid you are running under does not have permissions on the remote server. If you check the return code from the call (which you should be doing anyway), then $^E would probably tell you why it is failing.

BTW: The way you are calling the function twice, with list slices, to get two values that are both returned each time you make the call, is really crap coding. Try something like this:

use Win32::DriveInfo; use constant { SECTORS_PER_CLUSTER => 0, BYTES_PER_SECTOR => 1, FREE_CLUSTERS => 2, TOTAL_CLUSTERS => 3, BYTES_FREE_4_CALLER => 4, TOTAL_BYTES => 5, TOTAL_FREE => 6, }; my @info = Win32::DriveInfo::DriveSpace('\\\\server01\\d\$\\') or die "DriveSpace failed with error: $^E"; printf "%.3f GB free of total %.3f GB\n", $info[ TOTAL_FREE ] / 1024**3, $info[ TOTAL_BYTES ] / 1024**3;

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"I'd rather go naked than blow up my ass"

Replies are listed 'Best First'.
Re^2: Trying to get drive space info on remote Windows servers
by Cloudster (Novice) on Feb 18, 2010 at 15:54 UTC
    Thanks for the reply. I knew it was crap coding and I recognized that it was calling twice, I just wanted to get the basic functionality going before tightening it up properly. Since I was experimenting trying to get it to work, I wasn't too concerned about the crap at the moment. I'm not a heavy-duty Perl coder, I'm a database admin, and didn't know that I could simply tie an 'or die' to the function call for error trapping, normally I'm quite dogmatic about including that.

    Permissions isn't the issue, I'm using my network admin account when testing this. I was really wondering if I'm missing some sort of a network API call. The framework that this will fit in to reads and filters SQL Server logs every night, but that's just file I/O and works fine.

    Thanks again! I'll plug your code in and give it a shot.