exec() command and PATH issues

Reply

Join Date: Mar 2008
Posts: 38
Reputation: LeBurt is an unknown quantity at this point 
Solved Threads: 1
LeBurt LeBurt is offline Offline
Light Poster

exec() command and PATH issues

 
0
  #1
Mar 28th, 2008
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?

Thanks!
Last edited by LeBurt; Mar 28th, 2008 at 11:38 am.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 38
Reputation: LeBurt is an unknown quantity at this point 
Solved Threads: 1
LeBurt LeBurt is offline Offline
Light Poster

Re: exec() command and PATH issues

 
0
  #2
Mar 31st, 2008
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?

Thanks.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 1
Reputation: magicgunnar is an unknown quantity at this point 
Solved Threads: 0
magicgunnar magicgunnar is offline Offline
Newbie Poster

Re: exec() command and PATH issues

 
0
  #3
Mar 11th, 2009
You may try something like:
  1. 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!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC