problem : how to calculate disk space
Posted: Fri Dec 27, 2002 1:56 pm
Hello,
which is the best way to calculate disk usage on a directory (and its subdirectory) using php without receing errors if a not readable dir is found ?
I tried to use @shell_exec() and @passthru with the linux command du , but if "du" find some not readable directory it reports error (and there is no way to hide it )
Thanks
Graz
which is the best way to calculate disk usage on a directory (and its subdirectory) using php without receing errors if a not readable dir is found ?
I tried to use @shell_exec() and @passthru with the linux command du , but if "du" find some not readable directory it reports error (and there is no way to hide it )
Code: Select all
<?
ob_start();
@passthru("/usr/bin/du -sk /home/test");
$spacea = ob_get_contents();
ob_end_clean();
$spaceb = ereg_replace ("/home/test", "", $spacea);
$spaceb = str_replace(' ','',$spaceb);
$spacec = $spaceb/1024;
$spaced = number_format($spacec, 3, ',', ' ');
?>Thanks
Graz