hi guys,
hopefully someone here can help.. I have trawled every forum and googled for a week now, and still cant get this fixed..
I have CentOS4.2 installed, with apache2 and php4 rpm installs. httpd is running under user apache.
it appears to work ok.. however.. my problem...
DocumentRoot is set to /var/www/html
my php page is this r.php
<?
shell_exec("/tmp/ls.sh");
?>
/tmp/ls.sh consists of:
#!/bin/sh
ls -al > /tmp/output
when I load sr.php in a browser, nothing happens. ( I am not expecting anything on screen, but /tmp/output never gets created).
a tail of /var/log/http/error_log shows
sh: /tmp/ls.sh: Permission denied
now, /tmp has 777 perms, and if I run
su -c "/tmp/ls.sh" apache
the file /tmp/output gets created.
if I change sr.php to
<?
shell_exec("ls > /tmp/output");
?>
the file /tmp/output gets created!
Any ideas as to why I can not run user scripts from within PHP??
This has got me utterly beaten..
Thanks in advance
exec() problem with unix
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Hmm, that's weird if the file is 0777. It's even weirder if you can run ls but not your shell script.
Can you run any other bash or sh scripts from PHP? I'm guessing that your shell script doesn't really contain that code since you'd not bother with the script
I can't think of anything off the top of my head that would cause it if the file is really 0777. I assume the filesystem that it's on is not mounted with the noexec option?
Can you run any other bash or sh scripts from PHP? I'm guessing that your shell script doesn't really contain that code since you'd not bother with the script
I can't think of anything off the top of my head that would cause it if the file is really 0777. I assume the filesystem that it's on is not mounted with the noexec option?