Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Error with GetDRIVE() when using a mapped drive

by vanz (Initiate)
on Nov 03, 2014 at 16:52 UTC ( #1105922=note: print w/replies, xml ) Need Help??


in reply to Error with GetDRIVE() when using a mapped drive

Here is the result after adding or die "GetDrive failed $!"; in the script

Global symbol "$fs" requires explicit package name at E:\APPL\OEM\NetworkDriveCheck.pl line 9. Execution of E:\APPL\OEM\NetworkDriveCheck.pl aborted due to compilation errors.

  • Comment on Re: Error with GetDRIVE() when using a mapped drive

Replies are listed 'Best First'.
Re^2: Error with GetDRIVE() when using a mapped drive
by Loops (Curate) on Nov 03, 2014 at 17:02 UTC

    You have a syntax error in your edit. Likely a missing semicolon at the end of a line.

      Hi, Here is the script
      #!perl use warnings; use strict; use Win32::OLE; my $d = $fs->GetDrive('Y:') or die ; my $TotalSize = $d->{TotalSize}; my $FreeSpace = $d->{FreeSpace}; my $usedSpace = $d->{TotalSize} -= $d->{FreeSpace}; my $AvailableSpace = $d->{AvailableSpace} *=100; my $AvailUsed = $AvailableSpace /= $d->{TotalSize}; my $SpaceLeft = $d->{AvailableSpace} /= $AvailUsed; my $MappedDriveSpaceAvailable = $AvailUsed *= 100; print $MappedDriveSpaceAvailable;

      I have been looking and I do not see any syntax errors. any suggestions?

        Yes, you completely dropped the creation of the OLE filesystem object, thus $fs is left undefined. And you dropped the error message from the die statement.

        my $fs = Win32::OLE->CreateObject('Scripting.FileSystemObject'); my $d = $fs->GetDrive('Y:') or die "GetDrive failed $!";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1105922]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2022-06-30 16:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (98 votes). Check out past polls.

    Notices?