CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
How to get FreeSpace from remote Windows Server

 



drno-reg
New User

Jan 15, 2017, 6:24 AM

Post #1 of 1 (1189 views)
How to get FreeSpace from remote Windows Server Can't Post

Hello,

I know how get FreeSpace from local Windows Server

For examples:


Code
use warnings FATAL => 'all'; 
use strict;

#!perl
use Win32::OLE;
my $fs = Win32::OLE->CreateObject('Scripting.FileSystemObject');
my $d = $fs->GetDrive('c:');
print $d->{TotalSize}, " total\n";
print $d->{FreeSpace}, " free\n";
print $d->{AvailableSpace}, " available\n";
print $d->{TotalSize} - $d->{FreeSpace}, " used\n";


and else


Code
#!/usr/local/bin/perl 
use Win32::DriveInfo;
use strict;
use warnings;
print "OS Information\n";
my $computer=Win32::NodeName();
print "The computer name is $computer\n";

my %dtypes=(0 => "Undertmined",
1 => "Does Not Exist",
2 => "Removable",
3 => "Hardrive",
4 => "Network",
5 => "CDROM",
6 => "RAM Disk");

print "Drive Information\n";
my @drives = Win32::DriveInfo::DrivesInUse();
foreach my $drive (@drives){
my $type=Win32::DriveInfo::DriveType($drive);
print "Drive $drive is a $dtypes{$type}\n";

if (($drive eq 'C') | ($drive eq 'H')) {

my ($sectors, $bytessec, $freeclust, $clustnum, $userfree, $total, $totalfree)=Win32::DriveInfo::DriveSpace($drive);
#divide bytes to get gigabytes;
my $gbtotal = sprintf("%.2f", ($total/1073741824));
my $gbfree = sprintf("%.2f", ($totalfree/1073741824));
my $gbused = sprintf("%.1f", ($gbtotal - $gbfree));
my $free = $gbfree/$gbtotal;
my $perfree = sprintf("%.2f", ($free * 100));

#Print output
printf "$gbfree GB free from total of $gbtotal GB\n";
printf "total GB used $gbused\n";
printf "$perfree%% free on drive $drive\n";
printf "\n";

}
else {}
}

exit;


How to change code an opportunity to get FreeSpace from remote Windows Server?

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives