Jump to content

Finding Local Disk Space


navjak

Recommended Posts

Hi Guys,

 

Can any one tell me how to find the local disk space in php?

I tried the command df -h, it gives me the details of the space for local drives as well as for all the mapped drives. All I want is to get the disk space of local drives. df -l, doesnot work. I can get the space details if I hardcode the drive letter.

Need to find the local disk space without hardcoding the drive letters.

 

Please help me......

 

Thanks & Regards,

navjak.

Link to comment
Share on other sites

Thanks for the responce.

 

-----Need to find the local disk space without hardcoding the drive letters.

 

As I mentioned, I can get the diskspace of the local drive if I hardcode it. Need to find out the disk space of the local drives without hardcoding the drive letters.

 

navjak

Link to comment
Share on other sites

ok i tried everythink to solve your problam

i found that there meny errors using the disk_total_space function

so the only way was to do it as below ok.

 

dont forget the error_reporting will have to be turned off on this code ok.

 

 

this code will show on any windows meachine the drives and size of all drives a-z

not renamed drives.

<?php
error_reporting(0);

$a=disk_total_space("a:");
$b=disk_total_space("b:");
$c=disk_total_space("c:");
$d=disk_total_space("d:");
$e=disk_total_space("e:");
$f=disk_total_space("f:");
$g=disk_total_space("g:");
$h=disk_total_space("h:");
$i=disk_total_space("i:");
$j=disk_total_space("j:");
$k=disk_total_space("k:");
$l=disk_total_space("l:");
$m=disk_total_space("m:");
$n=disk_total_space("n:");
$o=disk_total_space("o:");
$p=disk_total_space("p:");
$q=disk_total_space("q:");
$r=disk_total_space("r:");
$s=disk_total_space("s:");
$t=disk_total_space("t:");
$u=disk_total_space("u:");
$v=disk_total_space("v:");
$w=disk_total_space("w:");
$x=disk_total_space("x:");
$y=disk_total_space("y:");
$z=disk_total_space("z:");

if($a){$a="disk a: ".disk_total_space("a:")." ";}

if($b){$b="disk b: ".disk_total_space("b:")." ";}

if($c){$c="disk c: ".disk_total_space("c:")." ";}

if($d){$d="disk d: ".disk_total_space("d:")." ";}

if($e){$e="disk e: ".disk_total_space("e:")." ";}

if($f){$f="disk f: ".disk_total_space("f:")." ";}

if($g){$g="disk g: ".disk_total_space("g:")." ";}

if($h){$h="disk h: ".disk_total_space("h:")." ";}

if($i){$i="disk i: ".disk_total_space("i:")." ";}

if($j){$j="disk j: ".disk_total_space("j:")." ";}

if($k){$k="disk k: ".disk_total_space("k:")." ";}

if($l){$l="disk l: ".disk_total_space("l:")." ";}

if($m){$m="disk m: ".disk_total_space("m:")." ";}

if($n){$n="disk n: ".disk_total_space("n:")." ";}

if($o){$o="disk o: ".disk_total_space("o:")." ";}

if($p){$p="disk p: ".disk_total_space("p:")." ";}

if($q){$q="disk q: ".disk_total_space("q:")." ";}

if($r){$r="disk r: ".disk_total_space("r:")." ";}

if($s){$s="disk s: ".disk_total_space("s:")." ";}

if($t){$t="disk t: ".disk_total_space("t:")." ";}

if($u){$u="disk u: ".disk_total_space("u:")." ";}

if($v){$v="disk v: ".disk_total_space("v:")." ";}

if($w){$w="disk w: ".disk_total_space("w:")." ";}

if($x){$x="disk x: ".disk_total_space("x:")." ";}

if($y){$y="disk y: ".disk_total_space("y:")." ";}

if($z){$z="disk z: ".disk_total_space("z:")." ";}

echo"$a <br>$b<br>$c<br>$d<br>$e<br>$f<br>$g<br>$h<br>
$i<br>$j<br>$k<br>$l<br>$m <br>$n<br>$o<br>$p<br>$q<br>
$u<br>$v<br>$w<br>$x<br>$y<br>$z<br>";
?> 

Link to comment
Share on other sites

sorry guys......I think Iam not clear enough of wht I want. I said I dont want to hardcode.

Let me explain it clearly wht Iam doing n wht I want.

 

I had written a php script on linux machine to find the disk space on windows machines(which is remote).

I had used ssh to run the df command.

 

"ssh -l <userid> <machinename> df -h c:"

 

This gives me the size,used,available and used % of the drive C. Similarly for D

 

"ssh -l <userid> <machinename> df -h d:"

if the local disk is partitioned.

 

If I dont mention any drive letter at the end

"ssh -l <userid> <machinename> df -h "

it gives the space for all the mapped drives + local drives(which are c/d/e/f.....).

 

For some machines the local disk may be any letter, which I cant know.

So I want to know the space of the local disks ONLY. I dont want to display all the drive spaces which are mapped on the remote machine.

 

Please help me..................

 

Thanks & Regards,

navjak

Link to comment
Share on other sites

I tried reinstalling Cygwin and used df -l. It gave me the result with local drives and also with the Cygwin path directories.(bin and lib directories)

How can I remove the cygwin path directories and get only the local drive space??

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.