Jump to content

[Solved] Directory Removal


Recommended Posts

Posted

Account details:

 

username:gfishing

domain:geoffish.heliohost.org

 

 

Problem:

 

I cannot remove the directory "/home/gfishing/public_html/drupal". I get permission denied errors, and other related problems when attempting to remove the directory via CPanel or FTP.

 

This is really weird, because I have never had this problem before. Just trying to install CMS (don't trust softalicious), and I attempted to move my installation to my document root, but could not.

 

If you could just remove the directory above for me, everything should be fine, unless I get more similar problems.

 

Thanks,

 

Geoff

Posted

Try running this perl script and don't forget to chmod it to 755.

 

#!/usr/bin/perl -w
print "Content-Type: text/html\n\n"; 
system 'rm -r "/home/gfishing/public_html/drupal" 2>&1';

 

Posted

I get the following error:

 

rm: cannot remove `/home/gfishing/public_html/drupal/sites/default/default.settings.php': Permission denied rm: cannot remove directory `/home/gfishing/public_html/drupal/sites/default/files': Permission denied rm: cannot remove `/home/gfishing/public_html/drupal/sites/default/settings.php': Permission denied

 

See for yourself here.

Posted

The folder "public_html/drupal/sites/default" had its permissions set to 555, preventing you from deleting it. In addition, the files "settings.php" inside the aforementioned folder was set to 444. After correcting both these settings, I was able to delete the folder.

Posted

Thanks

 

Edit: Here is the script for my own convenience if it is deleted:

 

<?php

function deleteDir($dir) {
   // open the directory
   $dhandle = opendir($dir);
   if ($dhandle) {
      // loop through it
      while (false !== ($fname = readdir($dhandle))) {
         // if the element is a directory, and 
         // does not start with a '.' or '..'
         // we call deleteDir function recursively 
         // passing this element as a parameter
         if (is_dir( "{$dir}/{$fname}" )) {
            if (($fname != '.') && ($fname != '..')) {
               echo "<u>Deleting Files in the Directory</u>: {$dir}/{$fname} <br />";
               deleteDir("$dir/$fname");

            }
         // chmod all directories and files correctly
         // the element is a file, so we delete it
         } else {
            chmod("$dir", intval(0755, 8));
            chmod("{$dir}/{$fname}", intval(0644, 8));
            unlink("{$dir}/{$fname}");
            echo "Deleting File: {$dir}/{$fname} <br />";
         }
      }
      closedir($dhandle);
    }
   // now directory is empty, so we can use
   // the rmdir() function to delete it
   echo "<u>Deleting Directory</u>: {$dir} <br />";
   rmdir($dir);
}
// call deleteDir function and pass to it 
// as a parameter a directory name
deleteDir("/home/username/public_html/delete");
?>

Guest
This topic is now closed to further replies.
×
×
  • Create New...