Been reading here for about an hour. I think I know the answer but maybe someone knows something I don't. Here's what I'm trying to do. I wrote a php program that extracts info from mysql and then attempts to write it to a file. The problem is the directories are 775 and the php script is nobody so it can't write the file. So I figured if I ran chmod(..., 0777) from the script and then changed it back all would be good. And it would have except the chmod command didn't run either. <br /><br />Anyone have any ideas? Or will I just have to chmod the dirs manually, write the files then chmod everything back?<!--content-->
<!--quoteo(post=182950:date=Jun 18 2006, 07:07 PM:name=old dan)--><div class='quotetop'>QUOTE(old dan @ Jun 18 2006, 07:07 PM) <a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=182950"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><div class='quotemain'><!--quotec-->I wrote a php program that extracts info from mysql and then attempts to write it to a file. The problem is the directories are 775 and the php script is nobody so it can't write the file.<!--QuoteEnd--></div><!--QuoteEEnd--><br />That would be a problem if you own the directory, which it appears that you do.<br /><br /><!--quoteo(post=182950:date=Jun 18 2006, 07:07 PM:name=old dan)--><div class='quotetop'>QUOTE(old dan @ Jun 18 2006, 07:07 PM) <a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=182950"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><div class='quotemain'><!--quotec-->So I figured if I ran chmod(..., 0777) from the script and then changed it back all would be good. And it would have except the chmod command didn't run either.<!--QuoteEnd--></div><!--QuoteEEnd--><br />Users can only do a chmod on directories and files that they own. Since your PHP script runs as 'nobody', it cannot change the permissions on a directory that is not owned by 'nobody'.<br /><br /><!--quoteo(post=182950:date=Jun 18 2006, 07:07 PM:name=old dan)--><div class='quotetop'>QUOTE(old dan @ Jun 18 2006, 07:07 PM) <a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=182950"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><div class='quotemain'><!--quotec-->Anyone have any ideas? Or will I just have to chmod the dirs manually, write the files then chmod everything back?<!--QuoteEnd--></div><!--QuoteEEnd--><br />You could set up your PHP script to run as a CGI script. As a CGI script, the script will run as "you" and avoid the permission problems you're currently having.<br /><br />In the directory where your script is, create an .htaccess file if there isn't one, or edit the existing one and add the following:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><Files myscriptname.php><br />Â Â AddHandler cgi-script .php<br /></Files><!--c2--></div><!--ec2--><br />Replace 'myscriptname.php' with the actual file name of your PHP script.<br /><br />Then, edit your script and insert the following as the very first line in your script:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->#!/usr/bin/php<!--c2--></div><!--ec2--><br />Finally, set the permissions on your PHP script to 0755 so it is executable.<br /><br />That should set you up. Leave the directory your script writes to with 0775 permissions and run the script - hopefully, the script will be able to create the file as you intend.<!--content-->
<!--quoteo(post=182965:date=Jun 19 2006, 04:38 AM:name=TCH-David)--><div class='quotetop'>QUOTE(TCH-David @ Jun 19 2006, 04:38 AM) <a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=182965"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><div class='quotemain'><!--quotec-->That would be a problem if you own the directory, which it appears that you do.<br />Users can only do a chmod on directories and files that they own. Since your PHP script runs as 'nobody', it cannot change the permissions on a directory that is not owned by 'nobody'.<br />You could set up your PHP script to run as a CGI script. As a CGI script, the script will run as "you" and avoid the permission problems you're currently having.<br /><br />In the directory where your script is, create an .htaccess file if there isn't one, or edit the existing one and add the following:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><Files myscriptname.php><br />Â Â AddHandler cgi-script .php<br /></Files><!--c2--></div><!--ec2--><br />Replace 'myscriptname.php' with the actual file name of your PHP script.<br /><br />Then, edit your script and insert the following as the very first line in your script:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->#!/usr/bin/php<!--c2--></div><!--ec2--><br />Finally, set the permissions on your PHP script to 0755 so it is executable.<br /><br />That should set you up. Leave the directory your script writes to with 0775 permissions and run the script - hopefully, the script will be able to create the file as you intend.<!--QuoteEnd--></div><!--QuoteEEnd--><br /><br /><br />cool, that sounds like it should work. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/clapping.gif" style="vertical-align:middle" emoid=":clapping:" border="0" alt="clapping.gif" /> I'll give it a try and let you know if it does.<br /><br />thanks a bunch. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/thumbup1.gif" style="vertical-align:middle" emoid=":thumbup1:" border="0" alt="thumbup1.gif" /><!--content-->
<!--quoteo(post=182980:date=Jun 19 2006, 08:10 AM:name=old dan)--><div class='quotetop'>QUOTE(old dan @ Jun 19 2006, 08:10 AM) <a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=182980"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><div class='quotemain'><!--quotec-->cool, that sounds like it should work. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/clapping.gif" style="vertical-align:middle" emoid=":clapping:" border="0" alt="clapping.gif" /> I'll give it a try and let you know if it does.<br /><br />thanks a bunch. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/thumbup1.gif" style="vertical-align:middle" emoid=":thumbup1:" border="0" alt="thumbup1.gif" /><!--QuoteEnd--></div><!--QuoteEEnd--><br /><br />yep that worked. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/clapping.gif" style="vertical-align:middle" emoid=":clapping:" border="0" alt="clapping.gif" /> Thank you very very much. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/thumbup1.gif" style="vertical-align:middle" emoid=":thumbup1:" border="0" alt="thumbup1.gif" /><!--content-->
<!--quoteo(post=182950:date=Jun 18 2006, 07:07 PM:name=old dan)--><div class='quotetop'>QUOTE(old dan @ Jun 18 2006, 07:07 PM) <a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=182950"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><div class='quotemain'><!--quotec-->I wrote a php program that extracts info from mysql and then attempts to write it to a file. The problem is the directories are 775 and the php script is nobody so it can't write the file.<!--QuoteEnd--></div><!--QuoteEEnd--><br />That would be a problem if you own the directory, which it appears that you do.<br /><br /><!--quoteo(post=182950:date=Jun 18 2006, 07:07 PM:name=old dan)--><div class='quotetop'>QUOTE(old dan @ Jun 18 2006, 07:07 PM) <a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=182950"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><div class='quotemain'><!--quotec-->So I figured if I ran chmod(..., 0777) from the script and then changed it back all would be good. And it would have except the chmod command didn't run either.<!--QuoteEnd--></div><!--QuoteEEnd--><br />Users can only do a chmod on directories and files that they own. Since your PHP script runs as 'nobody', it cannot change the permissions on a directory that is not owned by 'nobody'.<br /><br /><!--quoteo(post=182950:date=Jun 18 2006, 07:07 PM:name=old dan)--><div class='quotetop'>QUOTE(old dan @ Jun 18 2006, 07:07 PM) <a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=182950"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><div class='quotemain'><!--quotec-->Anyone have any ideas? Or will I just have to chmod the dirs manually, write the files then chmod everything back?<!--QuoteEnd--></div><!--QuoteEEnd--><br />You could set up your PHP script to run as a CGI script. As a CGI script, the script will run as "you" and avoid the permission problems you're currently having.<br /><br />In the directory where your script is, create an .htaccess file if there isn't one, or edit the existing one and add the following:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><Files myscriptname.php><br />Â Â AddHandler cgi-script .php<br /></Files><!--c2--></div><!--ec2--><br />Replace 'myscriptname.php' with the actual file name of your PHP script.<br /><br />Then, edit your script and insert the following as the very first line in your script:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->#!/usr/bin/php<!--c2--></div><!--ec2--><br />Finally, set the permissions on your PHP script to 0755 so it is executable.<br /><br />That should set you up. Leave the directory your script writes to with 0775 permissions and run the script - hopefully, the script will be able to create the file as you intend.<!--content-->
<!--quoteo(post=182965:date=Jun 19 2006, 04:38 AM:name=TCH-David)--><div class='quotetop'>QUOTE(TCH-David @ Jun 19 2006, 04:38 AM) <a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=182965"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><div class='quotemain'><!--quotec-->That would be a problem if you own the directory, which it appears that you do.<br />Users can only do a chmod on directories and files that they own. Since your PHP script runs as 'nobody', it cannot change the permissions on a directory that is not owned by 'nobody'.<br />You could set up your PHP script to run as a CGI script. As a CGI script, the script will run as "you" and avoid the permission problems you're currently having.<br /><br />In the directory where your script is, create an .htaccess file if there isn't one, or edit the existing one and add the following:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><Files myscriptname.php><br />Â Â AddHandler cgi-script .php<br /></Files><!--c2--></div><!--ec2--><br />Replace 'myscriptname.php' with the actual file name of your PHP script.<br /><br />Then, edit your script and insert the following as the very first line in your script:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->#!/usr/bin/php<!--c2--></div><!--ec2--><br />Finally, set the permissions on your PHP script to 0755 so it is executable.<br /><br />That should set you up. Leave the directory your script writes to with 0775 permissions and run the script - hopefully, the script will be able to create the file as you intend.<!--QuoteEnd--></div><!--QuoteEEnd--><br /><br /><br />cool, that sounds like it should work. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/clapping.gif" style="vertical-align:middle" emoid=":clapping:" border="0" alt="clapping.gif" /> I'll give it a try and let you know if it does.<br /><br />thanks a bunch. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/thumbup1.gif" style="vertical-align:middle" emoid=":thumbup1:" border="0" alt="thumbup1.gif" /><!--content-->
<!--quoteo(post=182980:date=Jun 19 2006, 08:10 AM:name=old dan)--><div class='quotetop'>QUOTE(old dan @ Jun 19 2006, 08:10 AM) <a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=182980"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><div class='quotemain'><!--quotec-->cool, that sounds like it should work. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/clapping.gif" style="vertical-align:middle" emoid=":clapping:" border="0" alt="clapping.gif" /> I'll give it a try and let you know if it does.<br /><br />thanks a bunch. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/thumbup1.gif" style="vertical-align:middle" emoid=":thumbup1:" border="0" alt="thumbup1.gif" /><!--QuoteEnd--></div><!--QuoteEEnd--><br /><br />yep that worked. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/clapping.gif" style="vertical-align:middle" emoid=":clapping:" border="0" alt="clapping.gif" /> Thank you very very much. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/thumbup1.gif" style="vertical-align:middle" emoid=":thumbup1:" border="0" alt="thumbup1.gif" /><!--content-->