calling mkdir from PHP


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers calling mkdir from PHP
# 1  
Old 06-15-2006
calling mkdir from PHP (Solved)

Edit: From a post in this topic, found out that my problem wasn't what I thought it was, and ended up solving my problem in aonther topic: https://www.unix.com/showthread.php?p...#post302076761




Hi, I'm not sure if this is a Unix problem or a PHP problem, but I'll see if anyone here knows.

So I have a PHP script that calls shell_exec('mkdir thefolder'); - for anyone who doesn't know php, shell_exec just throws a command at the command shell. "thefolder" is able to be created, BUT it is somehow created as read-only. When I click the file in Windows and try to uncheck the read-only, it won't let me. I tried deleting it through Unix, didn't work. The only way I could delete the folder was to use shell_exec('rm thefolder'); in PHP.

Now this makes no sense to me, shell_exec is just supposed to send a command to the Shell. calling 'mkdir thefolder' in Unix does not create it as read only, despite being the same command. As well, 'rm thefolder' does not work in the normal Unix, but the PHP script calls it fine.

I'm so confused. Any Ideas?

Thanks,
Graeme

Last edited by gmclean2006; 06-15-2006 at 12:29 PM..
# 2  
Old 06-15-2006
The PHP is running on a Web server (e.g. Apache) with the identity of a special user (e.g. nobody), and it makes sense that only that user on the system is able to remove the directory created by himself. Most Unix Web servers today are installed this way.
# 3  
Old 06-15-2006
Ok thanks, that makes sense.

But I'd assume if I could have it chmod'd so that all users have write access then there wouldn't be a problem? If thats the case then the other thread that i just posted "chmod - "future" changes", if that can get solved, it will probably solve the problem.
# 4  
Old 06-15-2006
oh but one question, is there anyway to change the user PHP is calling as from "nobody" to something else a little more secure?
# 5  
Old 06-15-2006
No, at least on the user (script) level.

However, you can configure Apache to run CGI scripts (recall that PHP scripts may be executed as CGI scripts with PHP CGI executable) in suEXEC mode, which allows scripts to run with the privileges of the script owner instead of the server user. But as I said, few servers I have seen are configured this way with suEXEC.

http://httpd.apache.org/docs/2.2/suexec.html
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Mkdir

hi linux expert what is a difference between: mkdir test and mkdir ./test and also if ( -e /test ) then and if ( -e ./test ) then thanks in advance Please use icode or code tags next time for your code and data (1 Reply)
Discussion started by: abdossamad2003a
1 Replies

2. Homework & Coursework Questions

Mkdir

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Do the procedure, which if there are 5 parameters then it creates 4 directories with names of 4 parameters, in... (2 Replies)
Discussion started by: bolones
2 Replies

3. Shell Programming and Scripting

calling awk from php not working

I want to run awk from php to do some text processing. I am giving an extremely simple example below: onecol.awk file ------------------- { print "Hello!"; } f1.txt --------- aaa ccc eee f2.txt --------- (6 Replies)
Discussion started by: mary271
6 Replies

4. Web Development

Permission problems calling Ruby from php script

I'm just getting my feet wet with web development, so hopefully this is a simple thing I'm overlooking, but so far I'm stumped. I have a php script that calls Ruby via exec(). This works fine in my test environment, but when I moved it to my production environment I run into a permissions... (7 Replies)
Discussion started by: dantes990
7 Replies

5. Shell Programming and Scripting

calling a php file from perl script..

Hi am new to perl script .. i need some useful tutorials links to learn perl script.. and a sample script to call a php file from perl script.. thanks.. (3 Replies)
Discussion started by: senkerth
3 Replies

6. Shell Programming and Scripting

Calling php from shell script

Maybe someone here can help out. I have a script cat <somefile> | while read hostname do /usr/bin/php <some php script> $hostname done This script works great for the first entry in the host list. However it will only execute and ignores the loop part. It's almost as if it loses... (4 Replies)
Discussion started by: dbakyle
4 Replies

7. Shell Programming and Scripting

Calling an Expect script from a Webpage using PHP

I have a webpage that is in HTML and PHP. In PHP I have tried using exec, system, shell_exec and passthru functions to call an Expect Script file (temp.exp). This Expect file spawns a telnet session that uses "expect/send" commands to retrieve information from an environmental unit (not a normal... (0 Replies)
Discussion started by: CCUSmith
0 Replies

8. Shell Programming and Scripting

Calling a shell script from php

Hi, I have a shell script and I'm trying to execute it from my php script. The command I'm using is: shell_exec("Script.sh"); Is this correct? It seems to not do anything for me. Not sure if this might be a permission issue or not. I have both scripts 777 permissions. Maybe I got the... (1 Reply)
Discussion started by: eltinator
1 Replies

9. UNIX for Advanced & Expert Users

mkdir

Is there ant way to increase max number of folders in the directory from the 32766: Problem UFS: shell>mkdir mmm mkdir: mmm: Too many links But there are no links, just folders. shell>ls | wc -l 32766 (3 Replies)
Discussion started by: mirusnet
3 Replies

10. UNIX for Dummies Questions & Answers

Calling a PHP script from cron

This is a line from my crontab: 12 12 * * * /home/users/ElburdNDL/www/backups/adddate.php The permissions of the script is 755 it should execute ok....but it doesn't. Do I somehow have to give cron the path to PHP or something? If so, how exactly? Thanks. Ed PS Am a total newbie... (10 Replies)
Discussion started by: eludlow
10 Replies
Login or Register to Ask a Question