Page 1 of 1

exec() troubles

Posted: Wed Oct 29, 2008 5:14 am
by The_Anomaly
Hey guys,


Well, I have my application working wonderfully on my local server, but when I deployed it to the web server, I'm having trouble. Everything is working alright, but the exec function seems to be acting rather stupid. For example:

Code: Select all

 
exec('ls')
 
Returns nothing, but gives me this line in the error log:

Code: Select all

 
sh: /ls: No such file or directory
 
So, I tried using absolute paths,

Code: Select all

exec('/etc/ls')
No difference, same error message. Not sure what to do with this. Every command I try gives me that same error. If you could give me some advice, I'd really appreciate it.

Extra info: Debian server, PHP 5, and all the commands work on command line.

Re: exec() troubles

Posted: Wed Oct 29, 2008 5:56 am
by impulse()
Try using

Code: Select all

$test = system('ls');
instead. That worked for me whereas exec() only returned the last file in the directory.

Re: exec() troubles

Posted: Wed Oct 29, 2008 6:03 am
by The_Anomaly
I figured out the problem...Safe_Mode is somehow enabled. I can't figure out how to get it out, even though it's disabled in the php.ini. I'd like to get rid of that, but until then I just set up the allowed safe_mode exec path and am using it from there.

However, now on my server, the output redirection is not working. Normally, my command is exec('command 2>&1') which gets my output. However, now that jut puts the following line in my error_log:

Code: Select all

Unable to find a suitable output format for '2>&1'