in reply to Re^4: Trying to get drive space info on remote Windows servers
in thread Trying to get drive space info on remote Windows servers

The problem is the regex on line 127 of DriveInfo.pm.

$drive =~ s/^(\\\\\w+\\\w+\$?)(\\)?$/$1\\/;

It doesn't allow for '-' in machine or path names. Switching that (and the 3 other occurances in the file) to

$drive =~ s/^(\\\\[^\\]+\\[^\\]+\$?)(\\)?$/$1\\/;

Allows the DriveSpace() call to work. At least using UNCs local on my machine. I haven't tested the other calls and that regex could probably be tighten back up a little.

It would also be good if you reported the problem back to the module's author. Then he can decide how much tighter to make it and test the other occurences.

You could also suggest changing all the occurances of return undef if/unless ...

to return if/unless ....

That'll ensure that the right flavour of undef is returned whatever the context, and allow the or die ... idiom to work properly in calling code.


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^6: Trying to get drive space info on remote Windows servers
by Cloudster (Novice) on Feb 19, 2010 at 15:09 UTC
    Thank you! I'll give it a shot later today. It's definitely an issue as all of our servers contain hyphens, it should have occurred to me that it could be an issue.

    Unfortunately I don't think contacting the author will do much good, his site is a .ru and hasn't been updated in a decade. But I'll give it a shot and we'll see what happens.
      Beauty! It works great! Now I just need to package it pretty in to a subroutine and integrate it with the rest of my code.

      I'll try to contact the driveinfo.pm author, if I don't hear back from him in a few weeks I'll post the update. All I changed was the regex expressions, I'm not going to touch the other changes that you recommend right now.

      Thanks again, all you monks!