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?


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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.