There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Php chmod doesn't see file


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
Zenoxio's Avatar
Computer Specs
Senior Member with 223 posts.
 
Join Date: Jul 2006
Location: Saratoga Springs, NY
Experience: Advanced
14-Jan-2008, 03:25 PM #1
Php chmod doesn't see file
Code:
[root@server data]# cat testconfig.php
<?php echo "test"; ?>

[root@server data]# php -r 'if (file_exists("testconfig.php")) echo "File exists.\n" ;'
File exists.

[root@server data]# php -r "chmod ("testconfig.php", 777);"

Warning: chmod(): No such file or directory in Command line code on line 1
The file exists. But why does chmod not see it?
tomdkat's Avatar
Computer Specs
Distinguished Member with 3,487 posts.
 
Join Date: May 2006
Location: S.F. Bay Area, CA
Experience: Intermediate
14-Jan-2008, 04:06 PM #2
Do you need to give the path to the file in the chmod command? What if you did this:

php -r "chmod ("./testconfig.php", 777);"

Peace...
Zenoxio's Avatar
Computer Specs
Senior Member with 223 posts.
 
Join Date: Jul 2006
Location: Saratoga Springs, NY
Experience: Advanced
14-Jan-2008, 04:13 PM #3
Doesn't seem to help. Here is a test script I tried:
Code:
<?php
$filename = "testconfig.php";
if (file_exists($filename)) {
    echo "The file $filename exists<br />";
} else {
    echo "The file $filename does not exist<br />";
}
echo "Attempting to chmod ".$filename;
chmod($filename, 0777);
?>
Which output:
Quote:
The file testconfig.php exists
Attempting to chmod testconfig.php
Warning: chmod() [function.chmod]: Operation not permitted in /home/protect/public_html/data/test.php on line 11

Last edited by Zenoxio : 14-Jan-2008 04:21 PM.
tomdkat's Avatar
Computer Specs
Distinguished Member with 3,487 posts.
 
Join Date: May 2006
Location: S.F. Bay Area, CA
Experience: Intermediate
14-Jan-2008, 04:49 PM #4
Well, this message:

Warning: chmod() [function.chmod]: Operation not permitted in /home/protect/public_html/data/test.php on line 11

means the id the chmod() is running under doesn't have permission to perform that operation which is different from the file not being found. You will need to address that problem first.

Peace...
Zenoxio's Avatar
Computer Specs
Senior Member with 223 posts.
 
Join Date: Jul 2006
Location: Saratoga Springs, NY
Experience: Advanced
14-Jan-2008, 04:52 PM #5
php is run as root. Root can chmod the file just fine using SSH.
tomdkat's Avatar
Computer Specs
Distinguished Member with 3,487 posts.
 
Join Date: May 2006
Location: S.F. Bay Area, CA
Experience: Intermediate
14-Jan-2008, 07:53 PM #6
Are you running the PHP script via a web server or via the command line? If you're running via web server, is the web server running as root or some other id? Can you run your script using the PHP CLI and post the output here?

Peace...

Last edited by tomdkat : 14-Jan-2008 09:35 PM.
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 09:18 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.