Welcome to WebmasterWorld Guest from 107.21.159.218

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Chmod script not working

     

chrissim

1:53 am on Feb 18, 2012 (gmt 0)

5+ Year Member



hi,

The following script below seem having problem with these error. i did tried to enter the full path to the file but seem not working.Please advise....


Warning: chmod() [function.chmod]: No such file or directory in /home/#*$!x/public_html/mysite.com/chmod.php on line 5




if(isset($_POST['dir'])){
$num = $_POST['num'];

chmod($dir, $num);
if(!$set){ echo "Error setting permissions"; } else { echo "Success!"; }

} else {
echo "<form action='$PHP_SELF' method='POST'>
Enter the directory to CHMOD
<input type='text' maxlength='48' length='24' name='dir'><br>
Enter permissions: <input type='text' maxlength='3' length='5' name='num'>
<input type='submit' name='chmod' id='chmod' value='chmod' />

</form>";

incrediBILL

2:21 am on Feb 18, 2012 (gmt 0)

WebmasterWorld Administrator incredibill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



What user is PHP running as?

In some installations it runs as Apache:Apache and others runs as the account Group:Owner , and can only set permissions on a directory if it's a directory where the permissions of PHP match those of the directory.

I have a situation on one server where I had to make a cron job running as root change the permissions on the directory for me because of such a mismatch problem. Normally it's something more easily fixed, but because I used a Plesk control panel for managing that server the cron job was the best solution I could find.

rocknbil

5:14 pm on Feb 20, 2012 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Right, it's not always permissions, sometimes it's ownership. An example, if you upload a file via FTP under your account user, then try to chmod it with a script, you will get permission denied, and vice versa. These are different owners.

But your error trapping (good!) is telling you what the problem is. No such file or directory (NOT permission denied.) And you likely want to use the full path.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month