Page 1 of 1

Why Program Execution Functions do not work correctly ?

Posted: Tue Aug 08, 2006 11:46 pm
by OmidReza
Hello,
My problem is :
Why Program Execution Functions do not work correctly ?
I attempt to run exec(),system(),shell_exec(),passthru()
but these functions do not work correctly although I use from filtering functions such as escapeshellarg() and escapeshellcmd() !!!
for example shell_exec('ls /') work correctly BUT shell_exec('ls /mnt') do not work !
Please help to me.
Thanks alot.

O.R.B

Posted: Tue Aug 08, 2006 11:47 pm
by feyd
usually it's a permissions problem.

Thanks about your answer BUT...

Posted: Wed Aug 09, 2006 3:03 am
by OmidReza
feyd wrote:usually it's a permissions problem.
-------------------------------------------------------------------------------------------
Hello,
Why the command exec( " ls / " ) works correctly but exec( " ls /mnt " ) or exec( " mkdir /newDir " ) or ... do not works ?
and for example : Why the return of system( " sendsms $telNum $msg " ) is 127 ? what is mean 127 ???
since I am in root I think it is not a permissions problem.
Thanks again.

Posted: Wed Aug 09, 2006 3:19 am
by AKA Panama Jack
You might want to read up on it...

http://us2.php.net/manual/en/ref.exec.php

The server can LIMIT what directories and executables you have access. You probably do not have permission to access those directories. Also, if the server has SELinux enabled then accessing files and executables is SEVERELY restricted. Safe Mode also adds access restrictions as well.

In many cases PHP is limited to accessing directories in the webroot. This is especially true on servers offering virtual hosting. Most do not like anyone having access to executables via PHP and block most of it. :)