Hi all,

I'm using exec() to launch external commands from a web application under OS X Leopard. To put my problem in context, when I launch this:

exec ("export", $output);

I get this:

export OLDPWD
export PATH="/usr/bin:/bin:/usr/sbin:/sbin"
export PWD="/Library/WebServer/Documents"
export SHLVL="1"

My problem is with PATH, I need to include other directories in there. I've been searching for some time now but can't put my finger on it. Any ideas?


10 Years
Discussion Span
Last Post by magicgunnar

There's nothing like posting a question to find the answer yourself shortly after...

I solved my problem by adding this at the beginning of my script:

putenv("PATH=" .$_ENV["PATH"]. "my/other/directories");

Works well, however I suspect there is another, more elegant, way to set the PATH in a .ini or .conf file somewhere. I looked at php.ini but didn't really see anything relevant in there.

Where might it be?



You may try something like:

SetEnv PATH my/other/directories

in your httpd.conf

I was running wamp under windows, and my solution was to set the windows path, and then rebooting. But your solution pointed me in the right direction, so thank you!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.