navjak Posted July 2, 2007 Share Posted July 2, 2007 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. Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 2, 2007 Share Posted July 2, 2007 <?php $x=disk_total_space("C:"); echo $x; ?> link http://uk.php.net/manual/en/function.disk-total-space.php Quote Link to comment Share on other sites More sharing options...
navjak Posted July 2, 2007 Author Share Posted July 2, 2007 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 Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 2, 2007 Share Posted July 2, 2007 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>"; ?> Quote Link to comment Share on other sites More sharing options...
DeathStar Posted July 2, 2007 Share Posted July 2, 2007 I would rather make it check with a foreach loop. Much less scripting and much faster. Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 2, 2007 Share Posted July 2, 2007 you did not read my post wont work with any loop that function dont you think i would off joke lol. Quote Link to comment Share on other sites More sharing options...
DeathStar Posted July 2, 2007 Share Posted July 2, 2007 Oh, okay. Sorry. you did not read my post wont work with any loop that function dont you think i would off joke lol. Quote Link to comment Share on other sites More sharing options...
navjak Posted July 2, 2007 Author Share Posted July 2, 2007 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 Quote Link to comment Share on other sites More sharing options...
trq Posted July 2, 2007 Share Posted July 2, 2007 What do you mean when you say df -l is not working? What output do you get? Quote Link to comment Share on other sites More sharing options...
navjak Posted July 2, 2007 Author Share Posted July 2, 2007 I just get the below message. Thats it. It does not display any size of the local drives. Filesystem 1K-blocks Used Available Use% Mounted on Quote Link to comment Share on other sites More sharing options...
navjak Posted July 3, 2007 Author Share Posted July 3, 2007 guys any update on the above issue?? Quote Link to comment Share on other sites More sharing options...
navjak Posted July 4, 2007 Author Share Posted July 4, 2007 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?? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.